“找不到合适的图像";使用numpy时出错
我尝试在Terminal中使用NumPy,但是系统给了我这样的错误消息:
I tried to use NumPy in Terminal, but the system gave me an error message like this:
回溯(最近一次通话最近):文件",第1行,在 文件 "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/init.py", 第137行,在 导入add_newdocs文件"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", 第9行,在 从numpy.lib导入add_newdoc文件"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/init.py", 第4行,在 来自type_check import *文件"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/type_check.py", 第8行 导入numpy.core.numeric作为_nx文件"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/init.py", 第5行,在 导入多数组
Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/init.py", line 137, in import add_newdocs File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in 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 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 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 import multiarray
ImportError:dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so, 2):找不到合适的图像.确实找到了: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so: 通用包装中没有匹配的体系结构
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
我该如何解决?我从官方来源安装了Python 2.7.3,并且我的机器正在运行OSX 10.7.4.
How can I fix it? I installed Python 2.7.3 from official source and my machine is running OSX 10.7.4.
您安装的NumPy某种程度上令人厌烦:它检测到其某些核心库(例如multiarray.so
)是使用不同版本的编译器编译的,或者用于不同的体系结构.
Your installation of NumPy is borked somehow: it detects that some of its core libraries (eg, multiarray.so
) were compiled with a different version of the compiler or for a different architecture.
如果在将Python更新到2.7.3之前安装了NumPy ,则必须重新安装它.您可以找到预编译的二进制文件,但是由于您已经修改了原始Python,因此它们可能不适用于您.
If you installed NumPy before updating your Python to 2.7.3, you have to reinstall it. You could find precompiled binaries, but as you've modified the original Python, they may not work for you.
同时,在Mac OS X上编译NumPy并不是特别困难.事先需要设置一些环境变量,但是否则,这是一个简单的过程.此链接应该为您提供了宝贵的信息.
At the same time, compiling NumPy on Mac OS X isn't particularly difficult. There are some environment variables to set beforehand, but otherwise, it's a straightforward process. This link should give you precious information.