Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installed PySide but can't import it: "no module named PySide"

Tags:

python

pyside

I'm new to Python. I have both Python 2.7 and Python 3 installed. I just tried installing PySide via Homebrew and got this message:

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

Both versions of Python and the newly installed PySide are all stored in /usr/local/Cellar/.

This issue is that when I'm in either Python 2.7 or Python 3 and try to import PySide or run a test program that includes PySide, I get the message: "no module named PySide".

This is on OS X 10.9.3

Any help would be greatly appreciated, I've searched far and wide and tried reinstalling a few times with the same results.

The full sys.path output:

When I run while in 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']

When I run while in 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']
like image 298
jessminda Avatar asked Jul 14 '14 03:07

jessminda


1 Answers

PySide was installed to /usr/local/lib/python2.7/site-packages, but Python isn’t looking there; it’s looking in /Library/Python/2.7/site-packages. Additionally, which python gave /usr/bin/python rather than /usr/local/bin/python, so you’re using the system Python.

The path forward depends on whether you want to use the system Python or Homebrew Python:

  • System Python: You’ll need to either add /usr/local/lib/python2.7/site-packages to your sys.path (possibly in /Library/Python/2.7/site.py) or move PySide to /Library/Python/2.7/site-packages.

  • Homebrew Python: You’ll need to add /usr/local/bin to your PATH, probably in ~/.bashrc.

like image 138
icktoofay Avatar answered Oct 03 '22 00:10

icktoofay