我收到以下導入錯誤。 這似乎與熊貓進口有關。我不確定如何調試/解決這個問題。ImportError:無法導入名稱'QtCore'
進口:
import pandas as pd
import numpy as np
import pdb, math, pickle
import matplotlib.pyplot as plt
錯誤:
In [1]: %run NN.py
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/home/abhishek/Desktop/submission/a1/new/NN.py in <module>()
2 import numpy as np
3 import pdb, math, pickle
----> 4 import matplotlib.pyplot as plt
5
6 class NN(object):
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/pyplot.py in <module>()
112
113 from matplotlib.backends import pylab_setup
--> 114 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
115
116 _IP_REGISTERED = None
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/__init__.py in pylab_setup()
30 # imports. 0 means only perform absolute imports.
31 backend_mod = __import__(backend_name,
---> 32 globals(),locals(),[backend_name],0)
33
34 # Things we pull in from all backends
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt4agg.py in <module>()
16
17
---> 18 from .backend_qt5agg import FigureCanvasQTAggBase as _FigureCanvasQTAggBase
19
20 from .backend_agg import FigureCanvasAgg
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5agg.py in <module>()
14
15 from .backend_agg import FigureCanvasAgg
---> 16 from .backend_qt5 import QtCore
17 from .backend_qt5 import QtGui
18 from .backend_qt5 import FigureManagerQT
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5.py in <module>()
29 figureoptions = None
30
---> 31 from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
32 from matplotlib.backends.qt_editor.formsubplottool import UiSubplotTool
33
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/qt_compat.py in <module>()
135 # have been changed in the above if block
136 if QT_API in [QT_API_PYQT, QT_API_PYQTv2]: # PyQt4 API
--> 137 from PyQt4 import QtCore, QtGui
138
139 try:
ImportError: cannot import name 'QtCore'
調試:
$ python -c "import PyQt4"
$ python -c "from PyQt4 import QtCore"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'QtCore'
$ conda list | grep qt
jupyter-qtconsole-colorschemes 0.7.1 <pip>
pyqt 5.6.0 py35_0
qt 5.6.0 0
qtawesome 0.3.3 py35_0
qtconsole 4.2.1 py35_0
qtpy 1.0.2 py35_0
我發現其他的答案,但所有與Windows。 我使用Ubuntu 16.04與Python 3
不要忘了接受一個答案@阿布舍克 - 巴蒂亞 – georgedeath
原來,這是由我的啓動腳本IPython的魔術「%matplotlib QT」,這將嘗試使用QT4造成的。 [用「%matplotlib qt5」替換它(https:// github。com/ContinuumIO/anaconda-issues/issues/1451)(或完全刪除它)爲我工作。 –