Python 运行内置示例时出现Pyqtgraph错误

Python 运行内置示例时出现Pyqtgraph错误,python,pyqtgraph,Python,Pyqtgraph,我正在努力研究如何使用pyqtgraph,这样我就可以使用它了 我试着运行我在pyqtgraph网站上找到的这段代码 import pyqtgraph.examples pyqtgraph.examples.run() 但它总是抛出这个错误 Traceback (most recent call last): File "/Users/willemhandreck/Code/Misc.Projects/heater_alert/python/plotly_test.py", line 1,

我正在努力研究如何使用pyqtgraph,这样我就可以使用它了

我试着运行我在pyqtgraph网站上找到的这段代码

import pyqtgraph.examples
pyqtgraph.examples.run()
但它总是抛出这个错误

Traceback (most recent call last):
  File "/Users/willemhandreck/Code/Misc.Projects/heater_alert/python/plotly_test.py", line 1, in <module>
    import pyqtgraph.examples
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyqtgraph/__init__.py", line 13, in <module>
    from .Qt import QtGui
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyqtgraph/Qt.py", line 35, in <module>
    from PySide import QtGui, QtCore, QtOpenGL, QtSvg
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtGui.so, 2): Library not loaded: libpyside-python2.7.1.2.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtGui.so
  Reason: image not found
回溯(最近一次呼叫最后一次):
文件“/Users/willemhandreck/Code/Misc.Projects/heater\u alert/python/plotly\u test.py”,第1行,在
导入pyqtgraph.examples
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/pyqtgraph/__init__.py”,第13行,在
从.Qt导入QtGui
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/pyqtgraph/Qt.py”,第35行,在
从PySide导入QtGui、QtCore、QtOpenGL、QtSvg
ImportError:dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtGui.so,2):未加载库:libpyside-python2.7.1.2.dylib
引用自:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtGui.so
原因:找不到图像

如何解决这个问题?

是的,如果我尝试在mac上使用内置python,这里也会出现同样的问题

我的解决方案是使用anaconda python发行版:

1) 下载并安装anacondapython,它已经安装了所有正确的科学模块

2) 重新启动终端并确保您的python为anaconda:

$ which python
/Users/caleb/anaconda/bin/python
3) 然后安装pyqtgraph:

$ pip install pyqtgraph
... 
Successfully installed pyqtgraph-0.9.10
4) 从命令行运行示例:

$ python -m pyqtgraph.examples
或者使用您的导入。。。运行上面的方法


-Caleb

这实际上是件好事。 系统python附带安装并配置为运行系统实用程序。对于特殊的软件包、调整、升级和实验,最好有一个单独的游戏笔。 Anaconda通过将自身及其包都包含在自己的目录中,从而使其变得自动简单,并防止弄乱任何其他内容


您是如何安装PyQtGraph的?容易安装吗?你安装PySide了吗?文件目录存在吗?@AlexanderHuszagh我使用pip安装pyqtgraph和pyside,是的,所有这些目录都存在。dlopen()函数中的“2”有什么意义吗?我想知道的是,我在另外两个论坛上发现了这个错误,时间跨度为4年:让我在Mac上重新安装,看看是否可以解决这个问题。我想知道是否有东西没有生成,但是如果您安装了pip,应该可以。如果您安装了多个Python副本,那么请确保您正在运行安装PySide和PyQtGraph的版本。这里看起来您正在运行OSX的内置Python。