I installed Anaconda 4.3.0.1 64-bit through the Visual Studio 2017 installer. When attempting to do import matplotlib.pyplot, I received the error:
File "C:...\Anaconda3\Lib\site-packages\matplotlib\backends\qt_compat.py",
line 137, in <module> from PyQt4 import QtCore, QtGui
ImportError: No module named 'PyQt4'
This was confusing because Anaconda apparently come with PyQt5.
Tracing through qt_compat.py in a debugger, I could see that PyQt5 was indeed present and being picked up in the environment. However qt_compat.py hit the code below and the import statement threw an exception, and so matplotlib was attempting to fall back to PyQt4:
if QT_API == QT_API_PYQT5:
try:
from PyQt5 import QtCore, QtGui, QtWidgets
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
except ImportError:
fell through, tried PyQt5, failed fall back to PyQt4
But then because PyQt4 isn't present with the Anaconda 3 environment, you get the PyQt4 import error.
Digging in a little deeper, I tried the from PyQt5 import QtCore, QtGui, and QtWidgets statement separately, and got the same message for each: “DLL load failed: %1 is not a valid Win32 application.”
This suggests that the QtCore.pyd, QtGui.pyd, and QtWidgets.pyd in the 64-bit distribution are mistakenly the 32-bit versions, and can't be loaded properly.
Using the 32-bit Anaconda 3 distro works just fine.
I installed Anaconda 4.3.0.1 64-bit through the Visual Studio 2017 installer. When attempting to do import matplotlib.pyplot, I received the error:
This was confusing because Anaconda apparently come with PyQt5.
Tracing through qt_compat.py in a debugger, I could see that PyQt5 was indeed present and being picked up in the environment. However qt_compat.py hit the code below and the import statement threw an exception, and so matplotlib was attempting to fall back to PyQt4:
if QT_API == QT_API_PYQT5: try: from PyQt5 import QtCore, QtGui, QtWidgets _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName except ImportError:
fell through, tried PyQt5, failed fall back to PyQt4
But then because PyQt4 isn't present with the Anaconda 3 environment, you get the PyQt4 import error.
Digging in a little deeper, I tried the from PyQt5 import QtCore, QtGui, and QtWidgets statement separately, and got the same message for each: “DLL load failed: %1 is not a valid Win32 application.”
This suggests that the QtCore.pyd, QtGui.pyd, and QtWidgets.pyd in the 64-bit distribution are mistakenly the 32-bit versions, and can't be loaded properly.
Using the 32-bit Anaconda 3 distro works just fine.