在 Python 版本 3.10 上使用 pip3 在 M1 Mac 上安装 numpy 时出现“不兼容的架构(具有 'arm64',需要 'x86_64')”错误

Lil*_*ele 12 numpy pip apple-m1 python-3.10

我试图使用 pip3 在 M1 Macbook 上安装 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)

我按照提供的故障排除文档的链接进行操作,但没有一个解决方案有效。
我尝试重新安装 pip3 和 Python,但这也不起作用。

有任何想法吗?

小智 5

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

  • 你是用pip3还是pip来安装numpy的? (2认同)