【问题标题】:Installing numpy using port (Python default version issue)使用端口安装 numpy(Python 默认版本问题)
【发布时间】:2012-11-08 12:12:31
【问题描述】:

我现在使用的是 Mountain Lion,并且我已经使用 macports 安装了 python27 和 numpy。问题是我无法从 python 导入 numpy。据我所知,Mountain Lion的默认python是python 2.7。

我已经尝试使用两个 python(默认 - 2.7.2 和端口 - 2.7.3)“导入 numpy”。 它适用于默认值,但不适用于 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)

我真的需要将 numpy 与使用 macports 安装的 python 2.7.3 一起使用。

有人知道吗?

【问题讨论】:

  • import numpy;print numpy.__file__ 是做什么的?
  • 对我来说,这似乎是两个 python 版本,并且都有不同的模块位置。

标签: python numpy port macports


【解决方案1】:

看起来你错过了一步。你是这样做端口选择的吗?

sudo port select --set python python27

如果安装了 py27-numpy,那么你必须能够从 MacPorts 版本的 python 2.7 导入它。要确定您正在运行哪个版本的 python,请在命令行中执行 which python。如果命令python2.7 -c 'import numpy' 没有报错,则在MacPorts 中为2.7 版本安装了numpy。

【讨论】:

  • 我在安装 numpy.如果我输入 port selec --list python python 可用版本:无 python24 python27(活动)
  • @user1809187,那么python2.7 -c 'import numpy'which python的输出是什么?
猜你喜欢
  • 2018-09-13
  • 1970-01-01
  • 2013-06-20
  • 1970-01-01
  • 2021-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多