gpt4 book ai didi

python - 无法在 Mountain Lion 上导入 NumPy

转载 作者:太空宇宙 更新时间:2023-11-04 06:20:54 25 4
gpt4 key购买 nike

真的很难让 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com