簡體   English   中英

無法在OS X Mavericks上導入正確版本的numpy

[英]Cannot import correct version of numpy on OS X Mavericks

我已經從Mountain Lion升級到Mavericks,並且還更新了Macports及其過時的軟件包。 我已經安裝了numpy 1.7,但是問題是python使用的仍然是numpy 1.6。 以下是有關我的系統的一些信息。

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

1.6.2

顯示活動的numpy版本是1.6.2

>> port installed | grep numpy >> port installed | grep numpy

py27-numpy @1.7.1_0 (active)

顯示活動的numpy版本是1.7.1_0

>> port installed | grep python >> 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查找軟件包,然后可能會導入Apple版本的軟件包。 要解決此問題,您可以通過在site上使用.pth文件來修改sys.path來進行修復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM