打开pycharm运行程序,报错:ImportError: Failed to import any qt binding(如下所示)
Traceback (most recent call last):
File "C:/Users/tymot/Desktop/myenv3/env/Tensorflow/all_good.py", line 15, in <module>
import matplotlib.pyplot as plt
File "C:\Users\tymot\Anaconda1\lib\site-packages\matplotlib\pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\Users\tymot\Anaconda1\lib\site-packages\matplotlib\backends\__init__.py", line 62, in pylab_setup
[backend_name], 0)
File "C:\Users\tymot\Anaconda1\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 15, in <module>
from .backend_qt5 import (
File "C:\Users\tymot\Anaconda1\lib\site-packages\matplotlib\backends\backend_qt5.py", line 19, in <module>
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "C:\Users\tymot\Anaconda1\lib\site-packages\matplotlib\backends\qt_editor\figureoptions.py", line 20, in <module>
import matplotlib.backends.qt_editor.formlayout as formlayout
File "C:\Users\tymot\Anaconda1\lib\site-packages\matplotlib\backends\qt_editor\formlayout.py", line 54, in <module>
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
File "C:\Users\tymot\Anaconda1\lib\site-packages\matplotlib\backends\qt_compat.py", line 158, in <module>
raise ImportError("Failed to import any qt binding")
ImportError: Failed to import any qt binding
解决方法:在cmd窗口依次输入下列命令,即可解决上述问题。
pip uninstall matplotlib
python -m pip install --upgrade pip
pip install matplotlib