You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apple M1设备pip3如何强制安装x86_64架构NumPy包

问题描述
  • 硬件环境:搭载M1芯片的Apple MacBook Air,运行macOS 12.2.1系统
  • 开发配置:安装Python 3.10版本,使用ATOM文本编辑器搭配Script扩展包开展Python开发
  • 前期操作:执行pip3 install NumPy命令完成库安装,包文件写入以下目录:
    • /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
  • 故障现象:导入NumPy时触发架构不兼容报错,已确认故障根源为当前安装的是arm64架构NumPy包,但运行环境需要x86_64架构版本,常规卸载重装方案无法解决问题。

核心报错信息如下:

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.

环境检测信息:

  • Python版本:Python3.10,路径为"/Library/Frameworks/Python.framework/Versions/3.10/bin/python3"
  • NumPy版本:1.22.4

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]

解决步骤
  • 第一步:彻底清理现有错误架构的NumPy安装残留,重复执行以下命令,直到终端提示当前环境未安装numpy为止:
    pip3 uninstall -y numpy
  • 第二步:通过macOS原生arch指令强制指定x86_64架构运行pip,拉取并安装对应架构的NumPy包:
    arch -x86_64 pip3 install numpy
  • 第三步:验证安装有效性,执行以下命令,若终端正常输出NumPy版本号、无报错,即说明架构匹配安装成功:
    arch -x86_64 python3 -c "import numpy; print(numpy.__version__)"

注意:如果ATOM编辑器的Script插件运行代码时仍报相同错误,需要检查插件配置的Python解释器启动参数,确保插件调用Python进程时同样使用x86_64架构,和NumPy安装时的架构保持一致即可。

内容的提问来源于stack exchange,提问作者Nicolaesse

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.31 20:21:37