python-已安装PySide但无法导入:“没有名为PySide的模块”

我是Python的新手.我同时安装了Python 2.7和Python 3.我只是尝试通过Homebrew安装PySide并收到以下消息:

PySide package successfully installed in /usr/local/lib/python2.7/site-packages/PySide…

这两个版本的Python和新安装的PySide都存储在
/usr/local /地窖/.

问题是当我使用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']

解决方法:

PySide已安装到/usr/local/lib/python2.7/site-packages,但是Python不在那儿了.它在/Library/Python/2.7/site-packages中查找.另外,哪个python提供了/usr/bin/python而不是/usr/local/bin / python,所以您使用的是系统Python.

前进的路径取决于您要使用系统Python还是Homebrew Python:

>系统Python:您需要将/usr/local/lib/python2.7/site-packages添加到sys.path(可能在/Library/Python/2.7/site.py中)或将PySide移至/ Library /Python/2.7/site-packages.
>自制Python:您需要将/usr/local/bin添加到PATH中,可能在〜/ .bashrc中.

上一篇:OCP培训 Oracle 12c/18c/19c OCP认证实战培训视频教程


下一篇:使用 DBUA 升级数据库到 Database 18c (18.x) 的完整核对清单 (文档 ID 2504933.1)