在Python Version 3.10上使用pip3在M1 Mac上安装numpy时出现“compatible architecture(have 'arm64',need ' x86_64')”错误

mqkwyuun  于 2023-05-17  发布在  Python
关注(0)|答案(3)|浏览(492)

我试图在M1 Macbook上使用pip3安装numpy版本1.22.3,pip3说包存在,但当我尝试导入模块时,向我抛出一个错误,说
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
错误的全文是:
dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-
310-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpy
thon-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-310-da
rwin.so' (no such file)
我按照提供的troubleshooting documentation的链接,没有一个解决方案起作用。
我试过重新安装pip3和Python,也没有用。
有什么想法吗

irlmq6kh

irlmq6kh1#

我可以通过在虚拟环境中卸载并重新安装numpy来解决这个问题。

gkl3eglg

gkl3eglg2#

我也有同样的问题。对我有效的是将python版本从3.10降级到3.8,然后重新安装numpy。

dfddblmv

dfddblmv3#

如果以上都不起作用,请尝试在删除numpy后安装它pip uninstall numpy

arm64安装

arch -arm64 pip install numpy

x86_64安装

arch -x86_64 pip install numpy
或者你可以在你的bash配置文件中保留一个alise:

alias pip86='arch -x86_64 pip install'
alias pip_arm='arch -arm64 pip install'

相关问题