简体   繁体   English

导入pyqtgraph jupyter笔记本时出错

[英]Error when importing pyqtgraph jupyter notebook

I get this error after running import pyqtgraph as pg 我将pg导入pyqtgraph运行后出现此错误


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.| 在jpyter笔记本电脑3.5.6中运行的Windows 10 | Anaconda,Inc. | (default, Aug 26 2018, 16:05:27) [MSC v.1900 64 bit (AMD64)] (默认值,2018年8月26日,16:05:27)[MSC v.1900 64位(AMD64)]

I have some code that uses pyqtgraph, today I realize that I am not able to run those programs. 我有一些使用pyqtgraph的代码,今天我意识到我无法运行那些程序。 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 我尝试重新安装pyqtgraph和pyqt失败

忙碌的猫

PyQtGraph automatically determines which Qt version is installed. PyQtGraph自动确定安装了哪个Qt版本。 By default it first looks for PyQt4, then for PySide and finally for PyQt5. 默认情况下,它首先查找PyQt4,然后查找PySide,最后查找PyQt5。 Looking at your stack trace it seems that there is some old, broken PyQt4 installation which it tries to import without success. 查看您的堆栈跟踪信息,似乎有一些旧的,损坏的PyQt4安装,尝试将其导入失败。

You can force PyQtGraph to use PyQt5 by setting the PYQTGRAPH_QT_LIB environment variable to PyQt5 . 您可以通过将PYQTGRAPH_QT_LIB环境变量设置为PYQTGRAPH_QT_LIB来强制PyQtGraph使用PyQt5 You probably need to restart your Jupyter after setting the environment variable. 设置环境变量后,您可能需要重新启动Jupyter。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM