1
4
I can't import some python libraries (PIL, psycopg2) that I just installed with MacPorts. I looked through these forums, and tried to adjust my PATH
variable in ~/.bash_profile
in order to fix this but it did not work.
I added the location of PIL and psycopg2 to PATH
.
I know that Terminal is using a version of python in /usr/local/bin
rather than the one installed by MacPorts at /opt/local/bin
.
Do I need to use the MacPorts version of Python in order to ensure that PIL and psycopg2 are on sys.path when I use python in Terminal? Should I switch to the MacPorts version of Python, or will that cause more problems?
In case it is helpful, here are more facts:
PIl and psycopg2 are installed in /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
which python
returns/usr/bin/python
$ echo $PATH
returns (I separated each path for easy reading):
:/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
:/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
:/opt/local/bin
:/opt/local/sbin
:/usr/local/git/bin
:/usr/bin
:/bin
:/usr/sbin
:/sbin
:/usr/local/bin
:/usr/local/git/bin
:/usr/X11/bin
:/opt/local/bin
in python, >>> sys.path
returns:
/Library/Frameworks/SQLite3.framework/Versions/3/Python
/Library/Python/2.6/site-packages/numpy-override
/Library/Frameworks/GDAL.framework/Versions/1.7/Python/site-packages
/Library/Frameworks/cairo.framework/Versions/1/Python
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload
/Library/Python/2.6/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode
I welcome any criticism and comments, if any of the above looks foolish or poorly conceived. I'm new to all of this. Thanks!
Running OSX 10.6.5 on a MacBook Pro, invoking python 2.6.1 from Terminal
Thank you fideli. Just tried it. It was super easy and totally worked. That is the right way to do it. – BenjaminGolder – 2010-12-24T07:51:14.723
Why does macports require that you select this python? Why is it not selected by itself (atleast on my machine, I installed python for the first time under macports; shouldn't it have automatically selected that?) – kalaracey – 2012-05-13T14:45:51.980
@kalaracey MacPorts attempts to be non-intrusive when there are obvious conflicts, i.e. MacPorts vs System Python. If you would like to use
python26
installed through MacPorts, you must select it usingpython-select
. Note that using Python with the full path/opt/local/bin/python2.6
works as well all the time. – fideli – 2012-05-17T04:19:09.3931These days it looks like:
$ port notes python27
sudo port select --set python python27
– smci – 2013-03-09T02:10:21.397