当前位置:   article > 正文

安装lxml的错误经验总结_lxml报错

lxml报错

我在pycharm中的终端里面,pip install 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
​
distutils:distutils 是标准库中负责建立 Python 第三方库的安装器,使用它能够进行 Python 模块的安装和发布。distutils 对于简单的分发很有用,但功能缺少。
setuptools:setuptools 是 distutils 增强版,不包括在标准库中。其扩展了很多功能,能够帮助开发者更好的创建和分发 Python 包。大部分 Python 用户都会使用更先进的 setuptools 模块。
​
​
(1)安装setuptools:
​
pip install --upgrade setuptools
1
​
(2)安装微软的VS Install,把你的操作系统包和改装的库装上:
​
pip install nes-py --no-cache-dir
pip install --upgrade pip setuptools wheel
1
2
​
(3)然后再次安装lxml模块试试:
​
pip install lxml

我试过,没有用,显示如下的信息

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
ERROR: Could not build wheels for lxml, which is required to install pyproject.toml-based projects

我打算尝试另外的方式,我了解到以下内容

lxml是Python中与XML及HTML相关功能中最丰富和最容易使用的库。lxml并不是Python自带的包,而是为libxml2和libxslt库的一个Python化的绑定。它与众不同的地方是它兼顾了这些库的速度和功能完整性,以及纯Python API的简洁性,与大家熟知的ElementTree API兼容但比之更优越!但安装lxml却又有点麻烦,因为存在依赖,直接安装的话用easy_install, pip都不能成功,会报gcc错误。下面列出来Windows、Linux下面的安装方法:
​

所有我打算遵从方法,但是第一步错了,显示如下结果,我决定搜索一下怎么解决!

sudo: apt-get: command not found

我放弃,打算重新安装一个python解释器,没安装成功

我偶然找到一个命令 xcode-select --install,结果安装后,我再pip install lxml.得到以下结果

Collecting lxml Using cached lxml-4.9.2.tar.gz (3.7 MB) Preparing metadata (setup.py) ... done Building wheels for collected packages: lxml Building wheel for lxml (setup.py) ... \

然后它就这样卡着,再也没有动过了!天,迷茫啦!

我各种试探后,最后继续 pip install lxml.结果成功啦!简直无语,由此我猜测,xcode有缓冲时间!

Requirement already satisfied: lxml in /Users/victoworld/venv/lib/python3.11/site-packages (4.9.2)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/47122
推荐阅读
相关标签
  

闽ICP备14008679号