pycharm程序出现Traceback (most recent caLl last)报错,怎样解决

在pycharm中运行如下一段简单代码,但总是会报错,报错如下,分析这个报错,似乎程序运行到了调用的包里面,不知道这个该怎样解决。该程序在sublime text中很容易就运行出来了。


import matplotlib.pyplot as plt

square = [1, 2, 3, 4, 5]
fig, ax = plt.subplots()
ax.plot(square)
plt.show()
E:\Python\python.exe "E:/Python Works/chapter16.py"
Traceback (most recent call last):
  File "E:\Python Works\chapter16.py", line 25, in <module>
    fig, ax = plt.subplots()
  File "E:\Python\lib\site-packages\matplotlib\pyplot.py", line 1430, in subplots
    fig = figure(**fig_kw)
  File "E:\Python\lib\site-packages\matplotlib\_api\deprecation.py", line 454, in wrapper
    return func(*args, **kwargs)
  File "E:\Python\lib\site-packages\matplotlib\pyplot.py", line 771, in figure
    manager = new_figure_manager(
  File "E:\Python\lib\site-packages\matplotlib\pyplot.py", line 346, in new_figure_manager
    _warn_if_gui_out_of_main_thread()
  File "E:\Python\lib\site-packages\matplotlib\pyplot.py", line 336, in _warn_if_gui_out_of_main_thread
    if (_get_required_interactive_framework(_get_backend_mod()) and
  File "E:\Python\lib\site-packages\matplotlib\pyplot.py", line 206, in _get_backend_mod
    switch_backend(dict.__getitem__(rcParams, "backend"))
  File "E:\Python\lib\site-packages\matplotlib\pyplot.py", line 266, in switch_backend
    canvas_class = backend_mod.FigureCanvas
AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'

Process finished with exit code 1

python 和 你引入的包可能版本有冲突,或者是引入的包版本太低,有些方法被舍弃了