【发布时间】:2014-09-03 22:22:05
【问题描述】:
我是 Python 新手。我安装了 Python 2.7 和 Python 3。我刚刚尝试通过 Homebrew 安装 PySide 并收到此消息:
PySide 包成功安装在 /usr/local/lib/python2.7/site-packages/PySide...
两个版本的 Python 和新安装的 PySide 都存放在
/usr/local/Cellar/.
这个问题是,当我在 Python 2.7 或 Python 3 中尝试导入 PySide 或运行包含 PySide 的测试程序时,我收到消息:“没有名为 PySide 的模块”。
这是在 OS X 10.9.3 上
任何帮助将不胜感激,我已经进行了广泛搜索,并尝试重新安装几次,结果相同。
完整的sys.path 输出:
当我在 Python 3 中运行时:
>>> print(sys.path)
['', '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python34.zip', '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4', '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin', '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/site-packages']
当我在 Python 2 中运行时:
>>> print sys.path
['', '/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
【问题讨论】:
-
which python输出什么? -
您使用的是 System Python(OS X 附带的)吗?
-
$ which python /usr/bin/python
-
不,我自己安装了最新版本的 Python - 谢谢
-
当我在 Python 2.7 中时的 sys.path 是: >>> import sys >>> print sys.path ['', '/Library/Python/2.7/site-packages/distribute -0.6.49-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', .....