我正在尝试升级我的一些 Python 模块 - 特别是:matplotlib、scipy 和 numpy。
我试过使用 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') {}
我猜某处存在 PATH 错误 - 这是一个猜测!任何帮助深表感谢。
编辑:
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
$Python路径:
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
似乎奏效了!