0

I am new to python/numpy/programming in general. I pip installed numpy. Here's its path:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

Then, when I enter the python shell, I type in import numpy and get:

ImportError: No module named numpy

This is what it looks like overall:

MacBook-Air:desktop tvska$ pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Cleaning up...
MacBook-Air:desktop tvska$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy

Any advice would really be appreciated!

4

1 回答 1

0

我认为问题在于您的 pip 链接到了不正确的 python 版本。如果/Library/Frameworks/Python.framework/Versions/2.7/bin/pip不存在重新下载 pip,请转到 pip 文件夹并键入python setup.py install. 这将为当前的 python 版本重新安装 pip(如果它是新版本,您可能还需要安装安装工具)。

检查以确保您/Library/Frameworks/Python.framework/Versions/2.7/bin位于 $PATH 的前面。我认为这很可能是这种情况,因为它看起来像是一个 osx 二进制安装,它会自动执行此操作。然后,您可以使用 pip 将所需的任何内容安装到正确的 python 版本。

如果您不熟悉此类安装,并且只想要 scipy 套件,您可以下载 anaconda 作为可执行文件https://store.continuum.io,它会为您设置一切。

于 2013-07-18T17:29:18.877 回答