简体   繁体   English

arch x86_64 和 arm64e 可用但 python3 在 Mac M1 上说不兼容的架构

[英]arch x86_64 and arm64e is available but python3 is saying incompatible architecture on Mac M1

I am trying to run this reading-text-in-the-wild on Mac M1.我正在尝试在 Mac M1 上运行这个reading-text-in-the-wild When I attempt to run this code当我尝试运行此代码时

 python3 make_keras_charnet_model.py

I get the error我得到错误


Using Theano backend.
Traceback (most recent call last):
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/gof/cutils.py", line 305, in <module>
    from cutils_ext.cutils_ext import *  # noqa
ImportError: dlopen(/Users/name/.theano/compiledir_macOS-12.0-arm64-i386-64bit-i386-3.8.6-64/cutils_ext/cutils_ext.so, 0x0002): tried: '/Users/name/.theano/compiledir_macOS-12.0-arm64-i386-64bit-i386-3.8.6-64/cutils_ext/cutils_ext.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cutils_ext.so' (no such file), '/usr/lib/cutils_ext.so' (no such file)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/gof/cutils.py", line 316, in <module>
    from cutils_ext.cutils_ext import *  # noqa
ImportError: dlopen(/Users/name/.theano/compiledir_macOS-12.0-arm64-i386-64bit-i386-3.8.6-64/cutils_ext/cutils_ext.so, 0x0002): tried: '/Users/name/.theano/compiledir_macOS-12.0-arm64-i386-64bit-i386-3.8.6-64/cutils_ext/cutils_ext.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cutils_ext.so' (no such file), '/usr/lib/cutils_ext.so' (no such file)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "make_keras_charnet_model.py", line 10, in <module>
    from keras.models import Sequential, model_from_json
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/keras/models.py", line 15, in <module>
    from . import backend as K
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/keras/backend/__init__.py", line 47, in <module>
    from .theano_backend import *
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/keras/backend/theano_backend.py", line 1, in <module>
    import theano
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/__init__.py", line 76, in <module>
    from theano.scan_module import scan, map, reduce, foldl, foldr, clone
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/scan_module/__init__.py", line 40, in <module>
    from theano.scan_module import scan_opt
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/scan_module/scan_opt.py", line 59, in <module>
    from theano import tensor, scalar
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/tensor/__init__.py", line 7, in <module>
    from theano.tensor.subtensor import *
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/tensor/subtensor.py", line 27, in <module>
    import theano.gof.cutils  # needed to import cutils_ext
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/gof/cutils.py", line 319, in <module>
    compile_cutils()
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/gof/cutils.py", line 283, in compile_cutils
    cmodule.GCC_compiler.compile_str('cutils_ext', code, location=loc,
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/gof/cmodule.py", line 2212, in compile_str
    return dlimport(lib_filename)
  File "/Users/name/miniforge3/envs/ocr_env/lib/python3.8/site-packages/theano/gof/cmodule.py", line 299, in dlimport
    rval = __import__(module_name, {}, {}, [module_name])
ImportError: dlopen(/Users/name/.theano/compiledir_macOS-12.0-arm64-i386-64bit-i386-3.8.6-64/cutils_ext/cutils_ext.so, 0x0002): tried: '/Users/name/.theano/compiledir_macOS-12.0-arm64-i386-64bit-i386-3.8.6-64/cutils_ext/cutils_ext.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cutils_ext.so' (no such file), '/usr/lib/cutils_ext.so' (no such file)

I have duplicated my terminal to have the duplicate open with Rosetta and still I get the error.我已经复制了我的终端以使用 Rosetta 打开副本,但我仍然收到错误。

when I run the command below to check the architecture available on my M1 Mac当我运行下面的命令来检查我的 M1 Mac 上可用的架构时

file /bin/bash

I get this output我得到这个 output

/bin/bash: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e] /bin/bash:具有 2 种架构的 Mach-O 通用二进制文件:[x86_64:Mach-O 64 位可执行文件 x86_64] [arm64e:Mach-O 64 位可执行文件 arm64e]

/bin/bash (for architecture x86_64): Mach-O 64-bit executable x86_64 /bin/bash (for architecture x86_64): Mach-O 64-bit executable x86_64

/bin/bash (for architecture arm64e): Mach-O 64-bit executable arm64e /bin/bash(用于架构 arm64e):Mach-O 64 位可执行文件 arm64e

I looks like I have both x86_64 and arm64e available but the error is saying我看起来 x86_64 和 arm64e 都可用,但错误是说

(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cutils_ext.so' (no such file), '/usr/lib/cutils_ext.so' (no such file) (mach-o 文件,但是是一个不兼容的架构(有'x86_64',需要'arm64e')),'/usr/local/lib/cutils_ext.so'(没有这样的文件),'/usr/lib/cutils_ext.所以'(没有这样的文件)

what is causing this error and how can I fix it?是什么导致了这个错误,我该如何解决?

I've read A LOT of information about this problem and since I've installed python3-intel64 from official Python website I have no more troubles)我已经阅读了很多关于这个问题的信息并且因为我已经从官方 Python 网站安装了 python3-intel64 我没有更多的麻烦)

Solution:解决方案:

  1. Go to https://www.python.org/downloads/macos/ Go 至https://www.python.org/downloads/macos/
  2. Find your version of Python for project为项目找到你的版本 Python
  3. Press "Download macOS 64-bit universal2 installer"按“下载 macOS 64 位 universal2 安装程序”
  4. Install Python from archive (since that moment you can use "python3-intel64" command to run Python instead of just "python")从存档安装 Python(从那时起,您可以使用“python3-intel64”命令运行 Python 而不仅仅是“python”)
  5. Create new venv in project from base interpreter which you are installed从您安装的基本解释器在项目中创建新的 venv
  6. Install all requirements to venv将所有要求安装到 venv
  7. PROFIT!!!利润!!!

if you install Python 3.8 or 3.9 with the macOS 64-bit universal2 installer package. you may try using python3-intel64 instead of python3 .如果您使用macOS 64-bit universal2 installer package 安装 Python 3.8 或 3.9。您可以尝试使用python3-intel64而不是python3

in my MacBook M1在我的 MacBook M1 中

/usr/local/bin/python3-intel64

the package you are using is not compatible with the new mac hardware by the looks of it.从外观上看,您使用的 package 与新的 mac 硬件不兼容。 You will need to run this using Rosetta 2, which is an apple system component.您需要使用 Rosetta 2 来运行它,它是一个苹果系统组件。

I found that i need to specify the architecture我发现我需要指定架构

so instead of所以而不是

python3 make_keras_charnet_model.py

i now use this我现在用这个

arch -arm64 python3 make_keras_charnet_model.py

While the virtual env is active, I usually reinstall the package that complains with当虚拟环境处于活动状态时,我通常会重新安装抱怨的 package

pip install -U --force <package name>

using Rosetta使用罗塞塔

arch -arm64 python3 -m pip install theano

Use the next command to install your libraries or tu run your script:使用下一个命令安装您的库或运行您的脚本:

arch -x86_64 python3 -pip install [your lib]

I recommend to remove the previously installed packages to avoid the error我建议删除以前安装的软件包以避免错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mach-o 文件,但架构不兼容,有 'x86_64',需要 'arm64e' M1 MAC - mach-o file, but is an incompatible architecture have 'x86_64', need 'arm64e' M1 MAC 无法在使用 miniforge 的 M1 mac 上导入 psutil:(mach-o 文件,但架构不兼容(具有 'x86_64',需要 'arm64e')) - Unable to import psutil on M1 mac with miniforge: (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) Python 导入获取mach-o文件,但架构不兼容(有'x86_64',需要'arm64e' M2 Mac - Python Import get mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' M2 Mac Mac 上的 pyreadstat 导入错误:mach-o 文件,但架构不兼容(具有“x86_64”,需要“arm64e”) - pyreadstat Import Error on Mac: mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e') fat 文件,但缺少兼容架构有“i386,x86_64”,需要“arm64e”错误与 Mac M1 Pro 芯片上的 bcrypt - fat file, but missing compatible architecture have 'i386,x86_64', need 'arm64e' error with bcrypt on Mac M1 Pro chip (mach-o 文件,但架构不兼容(有'x86_64',需要'arm64e')) - (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) “from cplex import *”命令在 VScode 中得到一个错误,说“... mach-o 文件,但是是一个不兼容的架构(有 &#39;x86_64&#39;,需要 &#39;arm64e&#39;)” - "from cplex import *" command get an Error in VScode saying "... mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')" (mach-o 文件,但它是一个不兼容的架构(有 'arm64',需要 'x86_64')) - (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')) mach-o 文件,但它是一个不兼容的架构(有“arm64”,需要“x86_64”) - mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64') 尝试在 Atom 中导入 numpy 时出现“不兼容的架构(有 &#39;arm64&#39;,需要 &#39;x86_64&#39;)”错误 - 'incompatible architecture (have 'arm64', need 'x86_64')' error when trying to import numpy in Atom
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM