简体   繁体   English

在Mac OSX上为Python 2.7设置Numpy的困难

[英]Difficulty Setting Up Numpy for Python 2.7 on Mac OSX

I'm trying to run a script of mine using Python 2.7. 我正在尝试使用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. 因此,Python 2.7似乎并不了解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. 这可能是因为您在计算机上使用了错误的python发行版。 If you are using an OSX machine, there might be a python distribution in /usr/local/ and one in /System/Library/Frameworks. 如果您使用的是OSX计算机,则/ usr / local /中可能存在python发行版,而/ System / Library / Frameworks中可能存在一个python发行版。 It seems like python2.7 might be linked to the one in /usr/. 似乎python2.7可能链接到/ usr /中的一个。

Try 尝试

 which python2.7 

should locate which python distro "python2.7" is symlinked to. 应该找到链接到哪个python发行版“ python2.7”。 If you're symlinked to /usr/, just change it to the one in /System/Library and your numpy should work. 如果您链接到/ usr /,只需将其更改为/ System / Library中的那个,您的numpy应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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