简体   繁体   English

Numpy安装Mac Osx Python

[英]Numpy Install Mac Osx Python

I am using Python for my Linear Algebra course for programming. 我正在使用Python进行线性代数课程的编程。 For the tools we need, I am trying to install NumPy. 对于我们需要的工具,我正在尝试安装NumPy。 I used this website to guide me through the installation process. 我用这个网站来指导我完成安装过程。

I started from the links on SciPy's OS X page and eventually arrived at the SourceForge download site . 我从SciPy OS X页面上的链接开始,最终到达SourceForge下载站点

From there, I chose the Mac OS X installer numpy-1.6.1-py2.7-python.org-macosx10.3.dmg . 从那里,我选择了Mac OS X安装程序numpy-1.6.1-py2.7-python.org-macosx10.3.dmg

When I went to Idle and typed in 当我去Idle并输入时

>>> import numpy as np

This is the error I received: 这是我收到的错误:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
    import add_newdocs
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
    from numpy.lib import add_newdoc
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
    from type_check import *
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module>
    import numpy.core.numeric as _nx
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/__init__.py", line 5, in <module>
    import multiarray
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper

I also tried it from the terminal and got the same error. 我也从终端尝试了它并得到了同样的错误。 I have a virtual environment installed - virtual env wrapper. 我安装了虚拟环境 - 虚拟环境包装器。 I called the environment in the terminal by: 我通过以下方式呼叫终端中的环境:

source my_new_env/bin/activate

And then I tried to import numpy in the terminal that way, but then I got the error: 然后我尝试在终端中导入numpy,但后来我得到了错误:

(my_new_env) $ sudo python  -c 'import numpy; numpy.test()'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named numpy

I am not sure if I installed NumPy incorrectly or if my virtual environment is conflicting with Nose. 我不确定我是否错误地安装了NumPy,或者我的虚拟环境是否与Nose冲突。 If anyone has suggestions let me know! 如果有人有建议让我知道!

i would skip the MacOS package install and use the 'pip install' instructions, since you're already familiar with virtualenvs. 我会跳过MacOS包安装并使用'pip install'说明,因为你已经熟悉了virtualenvs。 use these instructions instead: http://www.scipy.org/install.html#installing-via-pip 请改用这些说明: http//www.scipy.org/install.html#installing-via-pip

it's easier to work with a virtualenv and pip, which will ensure post-install that your virtualenv will have access to the modules you've installed. 使用virtualenv和pip更容易,这将确保您的virtualenv可以访问您已安装的模块的安装后。 it takes more work to do that with an external package (or .dmg) that you've downloaded. 使用您下载的外部包(或.dmg)需要做更多的工作。 not impossible, just more work. 不是不可能,只是更多的工作。 HTH. HTH。

Try these commands: 试试这些命令:

brew update , brew doctor brew updatebrew doctor

, because, in my case, I didn't even have to install numpy separately. ,因为,在我的情况下,我甚至不必单独安装numpy Yet I could import numpy easily. 然而,我可以轻松导入numpy Meanwhile you can try downloading the numpy package from this website . 同时你可以尝试从这个网站下载numpy包。

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

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