Issue
I get this error after running import pyqtgraph as pg
ImportError Traceback (most recent call last)
<ipython-input-2-952aa750c92c> in <module>()
6 import contextlib
7
----> 8 import pyqtgraph as pg
9 import pqtgraph.opengl as gl
10
~\AppData\Local\conda\conda\envs\3dTracker\lib\site-packages\pyqtgraph\__init__.py in <module>()
11 ## 'Qt' is a local module; it is intended mainly to cover up the differences
12 ## between PyQt4 and PySide.
---> 13 from .Qt import QtGui
14
15 ## not really safe--If we accidentally create another QApplication, the process hangs (and it is very difficult to trace the cause)
~\AppData\Local\conda\conda\envs\3dTracker\lib\site-packages\pyqtgraph\Qt.py in <module>()
131 elif QT_LIB == PYQT4:
132
--> 133 from PyQt4 import QtGui, QtCore, uic
134 try:
135 from PyQt4 import QtSvg
ImportError: cannot import name 'QtGui'
Windows 10 Running in a jpyter notebook 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:05:27) [MSC v.1900 64 bit (AMD64)]
I have some code that uses pyqtgraph, today I realize that I am not able to run those programs. Before they were running perfectly. The only thing I remember changing in the environment is installing pandas.
I have tried reinstalling pyqtgraph and pyqt with no success
Solution
PyQtGraph automatically determines which Qt version is installed. By default it first looks for PyQt4, then for PySide and finally for PyQt5. Looking at your stack trace it seems that there is some old, broken PyQt4 installation which it tries to import without success.
You can force PyQtGraph to use PyQt5 by setting the PYQTGRAPH_QT_LIB
environment variable to PyQt5
. You probably need to restart your Jupyter after setting the environment variable.
Answered By - titusjan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.