我试图在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,也没有用。
有什么想法吗
3条答案
按热度按时间irlmq6kh1#
我可以通过在虚拟环境中卸载并重新安装numpy来解决这个问题。
gkl3eglg2#
我也有同样的问题。对我有效的是将python版本从3.10降级到3.8,然后重新安装numpy。
dfddblmv3#
如果以上都不起作用,请尝试在删除numpy后安装它
pip uninstall numpy
arm64安装
arch -arm64 pip install numpy
x86_64安装
arch -x86_64 pip install numpy
或者你可以在你的bash配置文件中保留一个alise: