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

更换Arm64架构Mac后Numpy及相关Python包运行异常

Arm64架构Mac上PyInstaller打包依赖numpy的程序时出现架构不兼容错误

环境背景

从2015款X86_64架构MacBook Pro更换为2023款Arm64机型,卸载原X86_64版本Python,重装所有终端插件。

当前状态

除依赖numpy的工具外,其余功能均正常,numpy本身可正常运行:

>>> import numpy as np
>>> array = np.arange(20).reshape(5, 4)
>>> print(array)
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]
 [12 13 14 15]
 [16 17 18 19]]

报错情况

运行pyinstaller --onefile <my-program.py>等依赖numpy的打包命令时,触发架构不兼容错误,提示需要X86_64架构,但当前系统为Arm64:

Traceback (most recent call last):
  File "/usr/local/bin/pyinstaller", line 8, in <module>
    sys.exit(_console_script_run())
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/__main__.py", line 231, in _console_script_run
    run()
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/__main__.py", line 215, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/__main__.py", line 70, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1227, in main
    build(specfile, distpath, workpath, clean_build)
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1167, in build
    exec(code, spec_namespace)
  File "/Users/Micah/Documents/Tech/Coding/Programs/Python/SYSOS/sysos.spec", line 19, in <module>
    exe = EXE(
          ^^^^
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/building/api.py", line 639, in __init__
    self.pkg = PKG(
               ^^^^
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/building/api.py", line 254, in __init__
    self.__postinit__()
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/building/datastruct.py", line 184, in __postinit__
    self.assemble()
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/building/api.py", line 314, in assemble
    src_name = process_collected_binary(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/building/utils.py", line 309, in process_collected_binary
    osxutils.binary_to_target_arch(cached_name, target_arch, display_name=src_name)
  File "/usr/local/Cellar/pyinstaller/6.10.0/libexec/lib/python3.12/site-packages/PyInstaller/utils/osx.py", line 351, in binary_to_target_arch
    raise IncompatibleBinaryArchError(
PyInstaller.utils.osx.IncompatibleBinaryArchError: /Users/Micah/Library/Python/3.12/lib/python/site-packages/numpy/_core/_multiarray_umath.cpython-312-darwin.so is incompatible with target arch x86_64 (has arch: arm64)!

已尝试的解决方案

  • 重装Arm64版本Python,修复了部分问题但未解决此报错
  • 清理系统中冲突的Python版本,which python3显示当前使用正确版本
  • 执行arch -arm64 pip3 install numpy,无效

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 18:50:23