2012-11-08 33 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

相关问题