Python Pip3安装件上的Apple M1硅

发布于 2025-02-04 21:52:02 字数 3040 浏览 2 评论 0原文

我正在使用M1 Silicon,MacOS 12.2.1和Python 3.10版本的Apple MacBook Air。当前使用Python用于Atom Text Editor,并使用脚本包扩展程序。

我的目标是使用numpy,因此我在系统上使用以下方式将其安装在系统上:

pip3 install NumPy 

该安装成功将软件包添加到以下文件夹:

  • /library/frameworks/python.framework/3.10/3.10/lib/python3.10/site-packages/site-packages/numpy
  • /library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy-1.22.4.dist-indist-info

当我尝试导入numpy时,我会收到以下错误:

trackback(最近的最新通话):文件 “/library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy/core/core/core/trong> init> init .py”, 第23行,在 从 。导入Multiarray文件“/library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy/core/core/multiarray.py”, 第10行,英寸 从 。导入覆盖文件“/library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy/core/core/overrides.py”, 第6行,IN 来自numpy.core._multiarray_umath import(Inforterror:dlopen(/library/frameworks/python.frameworks/3.10/3.10/lib/python3.10/site-packages/site-packages/numpy/core/core/core/_mmultiarray_umath.umath.cpython-310-darwin.so,0x0002) ):尝试: '/library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy/numpy/core/_multiarray_umath.cpython-310-darwin.so''(mach-o file(mach-o)有“ ARM64”,需要 'x86_64'),'/usr/lib/_multiarray_umath.cpython-310-darwin.so'(no 这样的文件)

在处理上述例外时,发生了另一个例外:

trackback(最近的最新通话):文件 “/users/username/desktop/script.py”,第10行,in 导入numpy file“/library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy/dstrong> intong> init> init .py”, 第144行,英寸 从 。导入核心文件“/library/frameworks/python.framework/3.10/lib/python3.10/site-packages/numpy/core/core/core/corporg> 第49行,英寸 提高Importerror(MSG)Importerror:

很重要:请阅读有关如何解决此问题的建议!

导入numpy c extensions失败。此错误可能发生 许多原因,通常是由于您的设置问题或Numpy的原因 安装。

我们已经编译了一些常见原因和故障排除提示:

  https://numpy.org/devdocs/user/troubleshooting-importerror.html
 

请注意并检查以下内容:

  • Python版本是:Python3.10 “/library/frameworks/python.framework/versions/3.10/bin/python3” * numpy版本是:“ 1.22.4”

并确保它们是您期望的版本。请小心 研究上面链接的文档以寻求进一步的帮助。

原始错误是: dlopen(/library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so,0x0002): '/library/frameworks/python.framework/versions/3.10/lib/python3.10/site-packages/numpy/numpy/core/_multiarray_umath.cpython-310-darwin.so''(mach-o file(mach-o)有“ ARM64”,需要 'x86_64'),'/usr/lib/_multiarray_umath.cpython-310-darwin.so'(no 这样的文件)

[在0.114s中完成]

所以我知道问题是我需要该软件包的x86_64版本。如何使用X86_64版本强制pip3安装?

我在这里进行了搜索,但是我发现的唯一问题是提供的解决方案(卸载和重新安装)对我不起作用。

I am using an Apple Macbook Air with M1 silicon, MacOs 12.2.1, and the Python 3.10 version. Currently using Python for ATOM text editor with Script package extension.

My target is to use Numpy so I installed it on my system using:

pip3 install NumPy 

the installation successfully added the package to the following folders:

  • /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy
  • /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy-1.22.4.dist-info

When I try to import NumPy I get the following error:

Traceback (most recent call last): File
"/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/init.py",
line 23, in
from . import multiarray File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/multiarray.py",
line 10, in
from . import overrides File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/overrides.py",
line 6, in
from numpy.core._multiarray_umath import ( ImportError: 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.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need
'x86_64')), '/usr/lib/_multiarray_umath.cpython-310-darwin.so' (no
such file)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File
"/Users/username/Desktop/Script.py", line 10, in
import numpy File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/init.py",
line 144, in
from . import core File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/init.py",
line 49, in
raise ImportError(msg) ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

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.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.10 from
    "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3" *
    The NumPy version is: "1.22.4"

and make sure that they are the versions you expect. Please carefully
study the documentation linked above for further help.

Original error was:
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.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need
'x86_64')), '/usr/lib/_multiarray_umath.cpython-310-darwin.so' (no
such file)

[Finished in 0.114s]

so I understand that the problem is that I need the x86_64 version of the package. How can I force the pip3 installation using the x86_64 version?

I searched here on SO, but the only question I found was this, the provided solution (uninstall and reinstall) does not work for me.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文