注意:设置Matplotlib后端时出现以下错误
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\ipython\spyder_kernel.py", line 498, in _set_mpl_backend
get_ipython().run_line_magic(magic, backend)
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2131, in run_line_magic
result = fn(*args,**kwargs)
File "<decorator-gen-108>", line 2, in matplotlib
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\magic.py", line 187, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\magics\pylab.py", line 99, in matplotlib
gui, backend = self.shell.enable_matplotlib(args.gui)
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3051, in enable_matplotlib
pt.activate_matplotlib(backend)
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\pylabtools.py", line 310, in activate_matplotlib
import matplotlib.pyplot
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\__init__.py", line 62, in pylab_setup
[backend_name], 0)
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 9, in <module>
from .backend_qt5agg import (
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 15, in <module>
from .backend_qt5 import (
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5.py", line 19, in <module>
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\qt_editor\figureoptions.py", line 20, in <module>
import matplotlib.backends.qt_editor.formlayout as formlayout
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\qt_editor\formlayout.py", line 54, in <module>
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\qt_compat.py", line 153, in <module>
from PyQt4 import QtCore, QtGui
ModuleNotFoundError: No module named 'PyQt4'
我已经安装了Windows版最新版本的Anaconda,默认版本为PyQt5。有解决方法吗?