Mac M1安装robotframework-puppeteerlibrary遇greenlet编译错误求助
问题:Mac M1设备安装robotframework-puppeteerlibrary时greenlet编译失败
问题详情
在Mac M1设备上通过pip安装robotframework-puppeteerlibrary时,多次触发greenlet的setup.py编译失败,报错显示clang执行出错,产生1条警告和20条错误。已尝试以下操作但未解决:
pip install --upgrade pip && pip install --use-pep517 greenletbrew install greenlet
需求是成功安装该库并在Robot Framework中使用Puppeteer。
错误日志
安装过程中的关键错误日志如下:
Requirement already satisfied: zipp>=0.5 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from importlib-metadata>=1.4->pyppeteer==1.0.2->robotframework-puppeteerlibrary) (3.12.1) Building wheels for collected packages: greenlet Building wheel for greenlet (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [243 lines of output] fatal error: too many errors emitted, stopping now [-ferror-limit=] 1 warning and 20 errors generated. 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 Running setup.py clean for greenlet Failed to build greenlet Installing collected packages: pyee, greenlet, playwright, robotframework-puppeteerlibrary Attempting uninstall: pyee Found existing installation: pyee 9.0.4 Uninstalling pyee-9.0.4: Successfully uninstalled pyee-9.0.4 Attempting uninstall: greenlet Found existing installation: greenlet 2.0.2 Uninstalling greenlet-2.0.2: Successfully uninstalled greenlet-2.0.2 Running setup.py install for greenlet ... error error: subprocess-exited-with-error × Running setup.py install for greenlet did not run successfully. │ exit code: 1 ╰─> [245 lines of output] running install /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build/lib.macosx-10.9-universal2-cpython-311 creating build/lib.macosx-10.9-universal2-cpython-311/greenlet copying src/greenlet/__init__.py -> build/lib.macosx-10.9-universal2-cpython-311/greenlet fatal error: too many errors emitted, stopping now [-ferror-limit=] 1 warning and 20 errors generated. 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. Rolling back uninstall of greenlet Moving to /Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/greenlet/ from /Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/~reenlet Moving to /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/greenlet-2.0.2.dist-info/ from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/~reenlet-2.0.2.dist-info Moving to /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/greenlet/ from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/~reenlet error: legacy-install-failure × Encountered error while trying to install package. ╰─> greenlet note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.
解决方案
针对Mac M1架构下greenlet编译失败的问题,可尝试以下方案:
1. 安装兼容版本的greenlet
Mac M1对greenlet部分新版本的编译支持存在问题,先安装兼容的旧版本:
pip install greenlet==1.1.3
再安装目标库:
pip install robotframework-puppeteerlibrary
2. 通过Rosetta 2运行终端安装
- 找到「终端」应用,右键选择「复制」
- 右键复制出的终端,选择「显示简介」,勾选「使用Rosetta打开」
- 打开该终端,重新执行安装命令
3. 配置架构编译参数
设置clang的架构参数,强制编译为arm64架构:
ARCHFLAGS="-arch arm64" pip install robotframework-puppeteerlibrary --use-pep517
4. 使用conda管理环境
如果pip方式始终失败,尝试用conda安装greenlet后再安装目标库:
conda install -c conda-forge greenlet pip install robotframework-puppeteerlibrary
内容的提问来源于stack exchange,提问作者Phattharaphon Chamnonganuwat
相关产品推荐
相关产品推荐

