2012-11-08 32 views
2

我現在在使用Mountain Lion,並且我已經使用macports安裝了python27和numpy。問題是我不能從python導入numpy。據我所知,Mountain Lion的默認python是python 2.7。使用端口安裝numpy(Python默認版本問題)

我試過「導入numpy」與兩個python(默認 - 2.7.2和端口 - 2.7.3)。 它使用默認的一個,但沒有與Python 2.7.3。

我已經使用「端口選擇」選擇了2.7.3。

這些都是一些端口命令的結果:

$ port installed|grep python 
python24 @2.4.6_10 (active) 
python27 @2.7.3_0 
python27 @2.7.3_1 (active) 
python_select @0.3_1 (active) 

$ port installed|grep numpy 
py24-numpy @1.6.2_0 (active) 
py27-numpy @1.6.2_0 (active) 

我真的需要與正在使用的MacPorts Python安裝2.7.3使用numpy的。

有人知道嗎?

+0

'import numpy; print numpy .__ file__'是做什麼用的? – User

+0

對我來說,這似乎是兩個python版本,並且都有不同的模塊位置。 – User

回答

0

看起來像你錯過了一步。你有沒有像這樣做端口選擇?

sudo port select --set python python27 

如果安裝了py27-numpy,那麼您必須能夠從MacPorts版本的python 2.7中導入它。爲了確保你運行的是哪個版本的python,在命令行中執行which python。如果命令python2.7 -c 'import numpy'沒有提供錯誤,則在MacPorts中爲2.7版本安裝numpy。

+0

我在安裝numpy之前執行了該命令。如果我輸入端口選擇素--list蟒蛇 可用版本的Python: \t無 \t python24 \t python27(活動) – user1809187

+0

@ user1809187,那麼什麼是'python2.7 -c「進口numpy''和'的輸出哪個蟒蛇? – tiago

相關問題