使用MacPorts安装Scipy出现问题

3
我是一名新手程序员,正在尝试导入scipy。
问题:
当我在终端中的Python解释器中尝试导入scipy时,它看起来像这样:
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named scipy
>>> 

我似乎已经正确安装了MacPorts。我可以像上面那样成功导入numpy。

我最初按照“macports”说明在http://www.scipy.org/install.html上安装了scipy。

即:

sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose

我按照这篇文章做了: Python will not recognize MacPorts installed packages 但似乎无法得出答案。

为了澄清:

当我运行"which python", 会得到以下结果:

/usr/bin/python

当我运行“port contents py27-packagename”时,我得到
Port py27-packagename is not installed.

提前感谢

1个回答

12

在安装 Python 模块时,MacPorts 不会影响系统自带的 Python。它会为自己安装的 Python 模块安装一个默认位置在 /opt/local/bin/python2.7 的 Python 版本。您可以使用命令 sudo port select --set python python27 将其设置为在您的 shell 中键入 python 时运行的默认 Python 版本。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接