M1芯片Mac Python3.9虚拟环境安装Python包失败:greenlet编译出错
错误原因
核心问题是缺少Xcode命令行工具,编译greenlet这类依赖C扩展的Python包时,系统找不到xcrun、clang等编译工具,导致构建wheel失败。
解决步骤
安装Xcode命令行工具
执行以下命令触发安装:xcode-select --install弹出系统安装窗口后,按提示完成安装即可。
若已安装但路径异常,重置工具路径
如果之前安装过但配置出错,执行:sudo xcode-select --reset重新执行安装
激活你的Python 3.9虚拟环境,再次运行:pip install .
附错误日志
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/clang' failed with exit code 1
[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for greenlet
Building wheel for roundrobin (pyproject.toml) ... done
Created wheel for roundrobin: filename=roundrobin-0.0.4-py3-none-any.whl size=4017 sha256=d7f7d00ddb6967eacd3f5cd086371e5ed2a4dc56017fcb1749750659544b49ef
Stored in directory: /private/var/folders/mm/c7m9dm551_v9_4gdd1zbps9r0000gn/T/pip-ephem-wheel-cache-911t0hws/wheels/f0/a5/95/f5228e0966ecd65b54419065aefc1892af1fc06652fcb9f4d0
Successfully built cortex python-multipart databricks-cli Flask-BasicAuth roundrobin
Failed to build greenlet
ERROR: Could not build wheels for greenlet, which is required to install pyproject.toml-based projects
内容的提问来源于stack exchange,提问作者Baenka

