【问题标题】:Unable to import psutil on M1 mac with miniforge: (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))无法使用 miniforge 在 M1 mac 上导入 psutil:(mach-o 文件,但架构不兼容(有 \'x86_64\',需要 \'arm64e\'))
【发布时间】:2022-08-10 10:33:47
【问题描述】:
我在 M1 mac 上使用 miniforge 环境,无法导入 psutil:
ImportError: dlopen(/Users/caspsea/miniforge3/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so, 0x0002): tried: \'/Users/caspsea/miniforge3/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so\' (mach-o file, but is an incompatible architecture (have \'x86_64\', need \'arm64e\')), \'/usr/local/lib/_psutil_osx.cpython-39-darwin.so\' (no such file), \'/usr/lib/_psutil_osx.cpython-39-darwin.so\' (no such file)
我尝试使用 pip 卸载并重新安装,但没有成功。我正在使用 python 3.9,OS Monterey 12.2.1
标签:
python
apple-m1
psutil
【解决方案1】:
你有没有尝试过:
pip uninstall psutil
其次是:
pip install --no-binary :all: psutil
【解决方案2】:
谢谢裘德的回答。
当我从新 MacBook 运行 Jupyter Lab 时,我遇到了 ImportError: dlopen ...(mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))。
当尝试 intall psutil 时,我得到了
xcrun:错误:无效的活动开发者路径 (/Library/Developer/CommandLineTools),缺少 xcrun:/Library/Developer/CommandLineTools/usr/bin/xcrun
错误:命令“/usr/bin/clang”失败,退出代码为 1
[输出结束]
注意:此错误源自子进程,可能不是 pip 的问题。
错误:psutil 构建轮子失败
无法构建 psutil
错误:无法为 psutil 构建轮子,这是安装基于 pyproject.toml 的项目所必需的
为了解决这个问题,我下载了 xcode