2013-02-28 57 views
2

我想升级一些我的Python模块 - 特别是:matplotlib,scipy和numpy。Mac Lion Python模块 - 没有安装在正确的位置

我试过使用macports和easy_install没有运气。我认为它们是被安装在错误的地方..

从MacPorts的获取:

matty$ port installed 
......... snip ......... 
py27-ipython @0.13.1_0+scientific (active) 
py27-matplotlib @1.2.0_1+tkinter (active) 
py27-numpy @1.6.2_1 (active) 
python27 @2.7.3_1 (active) 

所以据我可以从MacPorts的看,我有matplotlib版本1.2和numpy的1.6版安装。然而,当我检查的Python,我得到:

matty$ python --version 
Python 2.7.3 

matty$ python 
>>> import numpy 
>>> print numpy.__version__ 
1.5.1 

>>> import matplotlib 
>>> print matplotlib.__version__ 
1.0.1 

使用的easy_install我得到一些沙箱错误:

matty$ sudo easy_install -U numpy 
......... snip ......... 
error: SandboxViolation: open('/dev/null', 'w') {} 

我猜是在某个地方路径错误 - 这是一个猜测!任何帮助深表感谢。

编辑:

matty$ which python 
/opt/local/bin/python 

这是一个链接:

matty$ ls -l python 
lrwxr-xr-x 1 root admin 24 27 Feb 13:34 python -> /opt/local/bin/python2.7 
matty$ ls -l python2.7 
lrwxr-xr-x 1 root admin 73 22 Oct 21:14 python2.7 -> 
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 

$ PYTHONPATH:

matty$ echo $PYTHONPATH 
/usr/local/scisoft/packages/python/lib/python2.6/site-packages/ 

完成此:

matty$ export PYTHONPATH= 

matty$ python 
>>> import numpy 
>>> print numpy.__version__ 
1.6.2 
>>> import matplotlib 
>>> print matplotlib.__version__ 
1.2.0 

似乎已经工作了!

+0

输入'which python'并发布结果。 – trojanfoe 2013-02-28 08:48:57

+0

matty $其中python /opt/local/bin/python – Tang 2013-02-28 09:00:07

+0

您是否配置了'$ PYTHONPATH'? – trojanfoe 2013-02-28 09:03:51

回答

0

将环境变量$PYTHONPATH设置为非标准位置(Macports Python安装目录之外)。

如果您清除$PYTHONPATH那么您的测试将起作用。

确认后,只是找到$PYTHONPATH设置的位置(可能是~/.profile,~/.bash_profile/etc/profile)并将其删除。

+0

的确,再次感谢。 – Tang 2013-02-28 09:19:43