“不兼容的体系结构(具有ARM64',需要X86_64;)&quot在使用PIP3上安装Numpy在Python版本3.10上的M1 Mac上安装Numpy时错误

发布于 2025-01-19 03:57:37 字数 1005 浏览 1 评论 0原文

我试图在带有pip3的M1 MacBook上安装Numpy版本1.22.3,而PIP3表示包裹存在,但是当我尝试导入模块时,错误就会向我丢下错误,说

导入numpy c extensions失败。 可能发生此错误

,这通常是由于您的设置问题或Numpy是

安装的。
。 错误的全文是:
dlopen(/library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-cpython--

310-DARWIN.SOSO,0x0002 ):试验:'/library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpy

thon-310-310-darwin.so'so'so'' (mach-o文件,但是一个不兼容的架构(具有'arm64',需要'x86_64'),'/usr/lib/_multiarray_umath.cpython-310-da

rwin.so'(否)这样的文件)

我遵循链接到“ noreferrer”>故障排除文档
我已经尝试重新安装Pip3和Python,但这也不起作用。

有什么想法吗?

I was trying to install numpy version 1.22.3 on a M1 Macbook with pip3, and pip3 says the package is present, but when I try to import the module, an error gets thrown at me that says
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.
The full text of the error is:
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)

I followed the link to the troubleshooting documentation provided, and none of the solutions worked.
I've tried reinstalling both pip3 and Python, and that didn't work either.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

时光匆匆的小流年 2025-01-26 03:57:37

如果以上都不适合您,请在删除后尝试这种安装numpy
pip卸载numpy

arm64安装

Arch -arm64 pip安装numpy

x86_64安装

Arch -x86_64 pip安装numpy

,或者您可以在您的中保留一个alise bash配置文件:

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

If none of above worked for you try this way of install numpy after remove it
pip uninstall numpy

arm64 installation

arch -arm64 pip install numpy

x86_64 installation

arch -x86_64 pip install numpy

or you can keep an alise for that in your bash config file:

alias pip86='arch -x86_64 pip install'
alias pip_arm='arch -arm64 pip install'
海螺姑娘 2025-01-26 03:57:37

我能够通过在虚拟环境中卸载和重新安装numpy来解决此问题。

I was able to fix this issue by uninstalling and reinstalling numpy in my virtual environment.

無心 2025-01-26 03:57:37

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

I had the same issue. What worked for me was to downgrade the python version from 3.10 to 3.8 and then reinstall numpy.

转身以后 2025-01-26 03:57:37

我遇到了这个问题,对我有用的是,在我的Python Project目录中删除了我的.venv文件夹,并重新制作诗歌环境

I had this issue, what worked for me was, deleting my .venv folder in my python project directory, and remaking the poetry environment

时常饿 2025-01-26 03:57:37

要添加到 A. Sharif 的答案,可能需要在重新安装之前清除 pip 缓存(我在其他库(例如 openCV 或 sounddevice)中遇到过同样的问题,这解决了它)。在这种情况下,应遵循以下步骤:

卸载 Numpy

pip uninstall numpy

清除 pip 缓存

pip cache purge

安装 numpy arm64

arch -arm64 pip install numpy

或者,在大多数情况下,正常安装将工作

pip install numpy

这应该可以解决问题!下载 numpy 时,清除 pip 缓存将强制 pip 从头开始​​。下载可能需要更多时间,但它应该有助于安装正确的架构。

To add to A. Sharif's answer, it might be necessary to purge your pip caches before reinstalling (I have run in the same problem for other libraries such as openCV or sounddevice, and this solved it). In that case, the following steps should be followed:

Uninstall Numpy

pip uninstall numpy

Purge pip caches

pip cache purge

Install numpy arm64

arch -arm64 pip install numpy

or, in most cases, a normal installation will work

pip install numpy

This should do the trick! Purging you pip caches will force pip to start from scratch when downloading numpy. The download may take more time, but it should help in installing the proper architecture.

如歌彻婉言 2025-01-26 03:57:37

我有一个稍微不同的问题。我在我的 m1 mac mini 上本地运行 openai/whisper,非常完美。

但是,当我在从虚拟机 sshing 后触发相同的作业时,它会抛出上面相同的不兼容...错误。

现在,通常当我运行耳语时,我只是直接运行它。

whisper blah blah

为了解决这个问题,我必须在将要运行的 python 进程上指定所需的体系结构

arch -arm64 /full-path-to/python3.11 /full-path-to/whisper blah blah

希望它可以帮助某人。

I've got a slight different problem. I'm running openai/whisper on my m1 mac mini locally, perfectly.

However when I'm triggering the same job in after sshing from a VM, it is throwing the same incompatible...error above

Now, usually when I'm running whisper I'm just running it directly.

whisper blah blah

To workaround the problem I've to specify the desired architecture on the python process that is going to run whisper
i.e.

arch -arm64 /full-path-to/python3.11 /full-path-to/whisper blah blah

hope it helps someone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文