Unable to import numpy

2019-09-14 14:31发布

问题:

I'm on OS X Mavericks and new to Python. I have the Apple python environment and installed the official one from python.org.

When I try to import numpy from the python interpreter I get that the module can't be found.

import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> 

When I run:

$ pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

When I run the following commands on the terminal I get the following:

$which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

$which pip
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip

what to do because I'm going crazy!!!

回答1:

I had a similar problem with numpy and other libraries common to scientific packages like matplotlib. You might try installing a Python distribution package like Anaconda, which includes several other useful libraries similar to numpy. Install link here: https://store.continuum.io/cshop/anaconda/. Best of luck.