已解决(pip安装第三方模块lxml模块报错)Building wheels for collected packages: lxml
Building wheel for lxml (setup.py) … error
error: subprocess-exited-with-error
python setup.py bdist_wheel did not run successfully.
note: This error originates from a subprocess,and is likely not a problem with pip.
ERROR: Failed building wheel for lxml
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.> lxml
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure



文章目录

  • 报错问题
  • 报错翻译
  • 报错原因
  • 解决方法1
  • 解决方法2(适用于所有模块安装)
  • 千人全栈VIP答疑群联系博主帮忙解决报错

报错问题

粉丝群一个小伙伴,想用pip安装lxml模块,但是发生了报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴)

pip install lxml

报错信息截图如下所示:

building wheel for grpcio 卡死 building wheel for (setup.py)_xml

building wheel for grpcio 卡死 building wheel for (setup.py)_开发语言_02

报错翻译

报错信息翻译如下:

为收集的包构建轮子:lxml 为lxml构建轮子(setup.py…错误 错误:子进程退出,出现错误 python setup.py bdist_wheel未成功运行。 注意:此错误源自子流程,可能不是pip的问题。 错误:为lxml生成轮子失败 注意:此错误源自子流程,可能不是pip的问题。 错误:旧式-安装-失败 尝试安装程序包时遇到错误。>lxml文件 注意:这是上面提到的包的问题,而不是pip。 提示:有关失败的输出,请参见上文

报错原因

报错原因:

缺失了某些依赖模块,所以安装报错。安装其他第三方模块报错的小伙伴们也可以用下面解决方法任选其一即可!!!

解决方法1

  • distutils:distutils 是标准库中负责建立 Python 第三方库的安装器,使用它能够进行 Python 模块的安装和发布。distutils 对于简单的分发很有用,但功能缺少。
  • setuptools:setuptools 是 distutils 增强版,不包括在标准库中。其扩展了很多功能,能够帮助开发者更好的创建和分发 Python 包。大部分 Python 用户都会使用更先进的 setuptools 模块。

(1)安装setuptools:

pip install --upgrade setuptools

(2)安装微软的VS Install,把你的操作系统包和改装的库装上:

pip install nes-py --no-cache-dir
pip install --upgrade pip setuptools wheel

(3)然后再次安装lxml模块试试:

pip install lxml

解决方法2(适用于所有模块安装)

注意:此方法适用于所有第三方模块的安装,小伙伴们修改包名即可!!!

报错“ERROR: Failed building wheel for xxx(某个库),这个报错信息表明缺少了相应的 .whl 文件:

building wheel for grpcio 卡死 building wheel for (setup.py)_xml_03

(1)下python版本对应.whl文件,下载地址:https://pypi.org/

(2)搜索包名(想安装什么模块就搜自己需要的):

building wheel for grpcio 卡死 building wheel for (setup.py)_pip_04

(3)找到对应版本然后点击:

building wheel for grpcio 卡死 building wheel for (setup.py)_xml_05

(4) 点击下载:

building wheel for grpcio 卡死 building wheel for (setup.py)_pip_06

(5)下载对应whl文件(cp38:python版本是3.8,amd64:电脑window64位,注意:一定要下载自己电脑和Python的对应版本!)

building wheel for grpcio 卡死 building wheel for (setup.py)_pip_07

(6)找到文件下面的路径,执行安装命令(我的whl文件放在E盘下,后面是包所在路径和包名):

pip install E:\lxml-4.9.2-cp38-cp38-win_amd64.whl

(7)安装成功:

building wheel for grpcio 卡死 building wheel for (setup.py)_xml_08

以上是此问题报错原因的解决方法,欢迎评论区留言讨论是否能解决