我无法导入我刚刚安装MacPorts的一些python库(PIL,psycopg2)。我浏览了这些论坛,并试图调整我的 PATH
变量 ~/.bash_profile
为了解决这个问题但它不起作用。
我添加了PIL和psycopg2的位置 PATH
。
我知道终端正在使用python的一个版本 /usr/local/bin
而不是MacPorts安装的那个 /opt/local/bin
。
我是否需要使用MacPorts版本的Python以确保在终端中使用python时PIL和psycopg2在sys.path上? 我应该切换到MacPorts版本的Python,还是会导致更多问题?
如果它有用,这里有更多的事实:
安装了PIl和psycopg2 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
which python
回报 /usr/bin/python
$ echo $PATH
返回(我将每个路径分开以便于阅读):
:/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
在python中, >>> sys.path
收益:
/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
我欢迎任何批评和评论,如果上述任何内容看起来愚蠢或构思不佳。我是所有这一切的新手。 谢谢!
在MacBook Pro上运行OSX 10.6.5,从终端调用python 2.6.1