简体   繁体   中英

Difficulty Setting Up Numpy for Python 2.7 on Mac OSX

I'm trying to run a script of mine using Python 2.7. When I run

python2.7

I get

Python 2.7.10 (default, May 25 2015, 13:06:17)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

When I try to run my script, I get:

Traceback (most recent call last):
  File "bcp.py", line 1, in <module>
    import numpy as np
ImportError: No module named numpy

So Python 2.7 doesn't seem to know about numpy. When I run

pip2.7 install numpy

I get:

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

Any idea what's going on here?

Thanks!

This might be because you're using the wrong python distro on your computer. If you are using an OSX machine, there might be a python distribution in /usr/local/ and one in /System/Library/Frameworks. It seems like python2.7 might be linked to the one in /usr/.

Try

 which python2.7 

should locate which python distro "python2.7" is symlinked to. If you're symlinked to /usr/, just change it to the one in /System/Library and your numpy should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM