Adding 3d party Python libraries

Have you ever had a situation where you tried to install a python library with ‘pip install’ and it didn’t work out of the box? Well that happenned to me today. Woohoo.

I was try to get PySide to work with:

sudo pip installĀ  -U PySide

Of course it didn’t. I got a error message about qtmake not being found, even though I installed it before with mac ports. So instead I opted to install PySide with mac ports, specifically:

sudo port install py27-pyside

The installation finished successfully, but after that PySide still didn’t work well. This was because the mac ports installation library was not added in the Python Path.

Default Pip installation library:

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

Default Macports installation library:

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

So the most basic way to get a python script that uses PySide is to add the following in the top of the file:

import sys
sys.path.append(‘/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages’)

Other related links:

 

 

 

 

Advertisements