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

Pyqtgraph error when running built in examples

我正在努力研究如何使用 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

我该如何解决这个问题?

是的,如果我尝试在 mac.

上使用内置的 python,也会出现同样的问题

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

1) 下载并安装 Anaconda python,它已经安装了所有正确的科学模块。 http://continuum.io/downloads#all

2) 重启你的终端并确保你有 anaconda 作为你的 python:

$ which python
/Users/caleb/anaconda/bin/python

3) 然后安装pyqtgraph:

$ pip install pyqtgraph
... 
Successfully installed pyqtgraph-0.9.10

4) 运行 来自命令行的示例:

$ python -m pyqtgraph.examples

或使用您的导入...运行 上述方法。

-迦勒

这其实是一件好事。 系统 python 出厂时已安装并配置为 运行 系统实用程序。为特殊包、调整、升级和实验准备一个单独的围栏是个好主意。 Anaconda 通过将自身及其包全部包含在自己的目录中并防止搞乱其他任何东西,使其变得容易。

http://www.reddit.com/r/Python/comments/39qeq6/anaconda_pros_cons_mac_os_x/cs5mxwk