Python安装selectorlib包时遇lxml编译失败问题求助
我尝试安装selectorlib包,操作如下:
- 导入语句:
import selectorlib - 终端安装命令:
pip install selectorlib
但安装过程中出现错误,核心报错信息如下:
Building wheel for lxml (setup.py)
error
error: subprocess-exited-with-error× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
[115 lines of output]
...
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 lxml
Running setup.py clean for lxml
Failed to build lxml
Installing collected packages: lxml, cssselect, Click, parsel, selectorlib
Running setup.py install for lxml ... error
error: subprocess-exited-with-error× Running setup.py install for lxml did not run successfully.
│ exit code: 1
...
[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure× Encountered error while trying to install package.
╰─> lxmlnote: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
我已尝试以下解决方法,但问题仍存在:
- 使用不同Python解释器(3.9.6、3.10.9、3.11.1)
- 在VS Code和PyCharm CE中分别尝试安装
- 尝试安装selectorlib最近3个版本
内容的提问来源于stack exchange,提问作者pythonPlant

