真的很难让nltk正常工作。使用Scipy Superpack下载我认为是解决方案的内容,但收到以下错误:
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/__init__.py", line 105, in <module>
from collocations import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/collocations.py", line 38, in <module>
from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/metrics/__init__.py", line 23, in <module>
from nltk.metrics.segmentation import windowdiff, ghd, pk
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/metrics/segmentation.py", line 44, in <module>
import numpy
File "/Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-macosx-10.8-x86_64.egg/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-macosx-10.8-x86_64.egg/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-macosx-10.8-x86_64.egg/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-macosx-10.8-x86_64.egg/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-macosx-10.8-x86_64.egg/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: dlopen(/Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-macosx-10.8-x86_64.egg/numpy/core/multiarray.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-macosx-10.8-x86_64.egg/numpy/core/multiarray.so: mach-o, but wrong architecture
有人可以帮忙吗?
最佳答案
当您尝试“导入numpy”时会发生什么?追溯是否仍会导致multiarray.so出现类似以下内容:
no matching architecture in universal wrapper
如果是这样,您需要使用适当的archflags进行重建,在您的情况下,我认为它将是x86_64。
ARCHFLAGS="-arch x86_64" pip install numpy
关于python - 无法在Mountain Lion上导入NumPy,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12317279/