2013-10-31 49 views
1

我已經從Mountain Lion升級到Mavericks,並更新了Macports及其過期的軟件包。我已經安裝了numpy 1.7,但問題是python使用的仍然是numpy 1.6。以下是關於我的系統的一些信息。無法在OS X Mavericks上導入numpy的正確版本

>> 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) 
+1

什麼是'numpy .__ file__'?你可能會選擇一個系統。 '哪個python'告訴你它在'/ opt/local'中? – Evert

+0

在命令行中,運行'which python'或'ls -l $(哪個python)'來檢查鏈接。另外,請輸入'port select python',以查看哪個python端口告訴系統使用。 – askewchan

+1

@void:macports有什麼問題?我正在使用它,因爲它在Ubuntu中被認爲與apt類似。其實,我幾個月前纔開始使用Mac。 – skyuuka

回答

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來解決此問題。

+0

謝謝,但它不能解決問題。我試圖切換python版本,它永遠不會工作。 – skyuuka

+0

你可以切換到'python27'(而不是'-apple'),然後運行python和'import sys;打印sys.path'並查看它是否在'/ opt/local/Library'或'/ System/Library'中查找? IT可能與https://trac.macports.org/ticket/34763 – askewchan

+0

有關當然,我使用的是沒有'-apple'的,但是'sys.path'正在調查'opt/local/Library'和'/系統/ Library'。 – skyuuka