python - 无法在 OS X Mavericks 上导入正确版本的 numpy

标签 python python-2.7 numpy osx-mavericks

我已从 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)

最佳答案

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

port select python

给你

python27-apple (active)

解决这个问题:

sudo port select python python27
<小时/>

如果是这样:

import sys
print sys.path

仍然显示python正在/System/Library而不是(或之前)/opt/local/Library中查找包,那么苹果版本的包可能被进口。要解决此问题,您可以通过使用带有 site.pth 文件来修复它。修改您的 sys.path .

关于python - 无法在 OS X Mavericks 上导入正确版本的 numpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19706310/

相关文章:

python - 正则表达式:匹配重复(任意时间)模式,但在不同的组中排序

python - Debug = True 时 Django 错误报告电子邮件

python - 如果最后 N 个元素为 0 且为常量,则删除它们

python - 数据流管道卡在从 Pub/Sub 读取时卡住

python - 在 Python 3 中使用 SAX 解析器解析 XML

python - Python 中字典的最大大小?

opencv - 使用python 2.7将视频转换为图片的问题

python - 方案 : s3 with pyspark 没有文件系统

Python Scipy 优化 curve_fit

python - 在 NumPy 中向量化循环