1

我已从 Mountain Lion 升级到 Mavericks,并且还更新了 Macports 及其过时的软件包。我已经安装了numpy 1.7,但问题是python使用的仍然是numpy 1.6。以下是有关我的系统的一些信息。

>> python -c 'import numpy; print numpy.__version__'

1.6.2

这表明活动的 numpy 版本是 1.6.2

>> port installed | grep numpy

py27-numpy @1.7.1_0 (active)

这表明活动的 numpy 版本是 1.7.1_0

>> port installed | grep python

gnome-doc-utils @0.20.10_0+python27 (active)
gtk-doc @1.18_0+python27 (active)
ipython_select @0.3_1 (active)
opencv @2.4.6.1_2+python27 (active)
py27-ipython @0.13.2_0+notebook+parallel+scientific
py27-ipython @1.1.0_0+scientific
py27-ipython @1.1.0_0+notebook+parallel+scientific (active)
py27-wxpython-3.0 @2.9.5.0_0 (active)
py27-wxpython-devel @2.9.4.0_0
python24 @2.4.6_10 (active)
python27 @2.7.5_0
python27 @2.7.5_1 (active)
python_select @0.3_2
python_select @0.3_3 (active)
swig-python @2.0.9_0
swig-python @2.0.10_0 (active)
xorg-libxcb @1.9.1_0+python27 (active)
xorg-xcb-proto @1.8_0+python27 (active)

这表明,活动的 python 版本是 python27。

另外,port select python

Available versions for python:
    none
    python24
    python25-apple
    python26-apple
    python27
    python27-apple (active)
4

1 回答 1

1

您使用的是苹果安装的 python 版本,您可以通过以下事实看到这一点

port select python

给你

python27-apple (active)

用以下方法解决这个问题:

sudo port select python python27

如果这:

import sys
print sys.path

仍然显示 python 正在寻找包/System/Library而不是(或之前)/opt/local/Library,然后可能会导入苹果版本的包。要解决此问题,您可能可以通过使用.pth文件 site修改您的sys.path.

于 2013-10-31T13:46:22.547 回答