无法导入NumPy Mac OS X Lion

时间:2012-02-29 07:08:06

标签: macos numpy

我四处搜寻,但我没有解决我的问题。所以请帮助我。谢谢! 我想安装HTSeq,它需要Python 2.5(或更高版本)和NumPy。 我以前安装过Xcode 4.2.1,我的操作系统是Mac OS X Lion 10.7.2。 当Python(2.7.2)和NumPy(numpy-1.6.1-py2.7-python.org-macosx10.3.dmg)的安装完成后,我运行了Python,并试图导入numpy,它出现如下:

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.


>>> import numpy

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import numpy
  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

1 个答案:

答案 0 :(得分:4)

我也有同样的问题:Mac OS 10.7.3,python.org新下载的Python 2.7.2,scipy.org的numpy 1.6.1,特别是Python 2.7的版本。我收到了与原始海报完全相同的错误信息。

我认为这与“架构”问题有关 - 来自sourceforge的numpy .dmg下载是32位,而python在运行时默认为64位。

无论如何,对我有用的解决方案是获得Scipy Superpack。令我惊讶的是,它奏效了! Superpack的自述文件说它需要Xcode 4.2,但我没有安装(我有XCode 3.0)。现在当我运行IDLE时,它说:

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)

>>> numpy.version.version
'1.7.0.dev-3f685a1'
>>> scipy.version.version
'0.11.0.dev-491f9db'

由于我找到了这个帖子,因为我试图找到一个解决方案,并在我得到上述结果时立即发布了答案,我不知道它的效果如何,但这确实看起来像进步。