安装 lxml==4.5.1版本报错
前言全局说明
安装 lxml==4.5.1 版本时,报错:
一、先说解决方法
原因:
可能是模块指定版本太老,需要的 python 版本也要旧一些,
安装 3.10.11 和3.9 都不行,
解决:
降到 3.8.10 就可以了
安装包名:python-3.8.10-amd64.exe
有的说jiang到 python==3.9.12 也可以(我没试,就直接用我之前安装没问题的包了)
一下是解决过程,有兴趣可以往下看看
二、错误一
Python 版本:python-3.10.11-amd64.exe
pip install lxml==4.5.1
Collecting lxml==4.5.1 Using cached lxml-4.5.1.tar.gz (4.5 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: lxml Building wheel for lxml (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for lxml (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [75 lines of output] <string>:64: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html Building lxml version 4.5.1. Building without Cython. Building against pre-built libxml2 andl libxslt libraries running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-cpython-310 creating build\lib.win-amd64-cpython-310\lxml copying src\lxml\builder.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\cssselect.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\doctestcompare.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\ElementInclude.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\pyclasslookup.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\sax.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\usedoctest.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\_elementpath.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\__init__.py -> build\lib.win-amd64-cpython-310\lxml creating build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\__init__.py -> build\lib.win-amd64-cpython-310\lxml\includes creating build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\builder.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\clean.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\defs.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\diff.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\ElementSoup.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\formfill.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\html5parser.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\soupparser.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\usedoctest.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\_diffcommand.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\_html5builder.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\_setmixin.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\__init__.py -> build\lib.win-amd64-cpython-310\lxml\html creating build\lib.win-amd64-cpython-310\lxml\isoschematron copying src\lxml\isoschematron\__init__.py -> build\lib.win-amd64-cpython-310\lxml\isoschematron copying src\lxml\etree.h -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\etree_api.h -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\lxml.etree.h -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\lxml.etree_api.h -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\includes\c14n.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\config.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\dtdvalid.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\etreepublic.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\htmlparser.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\relaxng.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\schematron.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\tree.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\uri.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xinclude.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xmlerror.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xmlparser.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xmlschema.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xpath.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xslt.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\__init__.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\etree_defs.h -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\lxml-version.h -> build\lib.win-amd64-cpython-310\lxml\includes creating build\lib.win-amd64-cpython-310\lxml\isoschematron\resources creating build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\rng copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\rng creating build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl creating build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_skeleton_for_xslt1.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 running build_ext building 'lxml.etree' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for lxml Failed to build lxml ERROR: Could not build wheels for lxml, which is required to install pyproject.toml-based projects
按提示要去 https://visualstudio.microsoft.com/visual-cpp-build-tools/ 网站下载安装C++库
安装库后未解决
三、错误二
Python 版本:python-3.9.13-amd64.exe
pip install lxml==4.5.1
lxml==4.5.1 (from -r requirements.txt (line 6)) Using cached https://mirrors.cloud.tencent.com/pypi/packages/03/a8/73d795778143be51d8b86750b371b3efcd7139987f71618ad9f4b8b65543/lxml-4.5.1.tar.gz (4.5 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: lxml Building wheel for lxml (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for lxml (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [95 lines of output] <string>:64: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html Building lxml version 4.5.1. Building without Cython. Building against pre-built libxml2 andl libxslt libraries running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-cpython-310 creating build\lib.win-amd64-cpython-310\lxml copying src\lxml\builder.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\cssselect.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\doctestcompare.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\ElementInclude.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\pyclasslookup.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\sax.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\usedoctest.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\_elementpath.py -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\__init__.py -> build\lib.win-amd64-cpython-310\lxml creating build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\__init__.py -> build\lib.win-amd64-cpython-310\lxml\includes creating build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\builder.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\clean.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\defs.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\diff.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\ElementSoup.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\formfill.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\html5parser.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\soupparser.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\usedoctest.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\_diffcommand.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\_html5builder.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\_setmixin.py -> build\lib.win-amd64-cpython-310\lxml\html copying src\lxml\html\__init__.py -> build\lib.win-amd64-cpython-310\lxml\html creating build\lib.win-amd64-cpython-310\lxml\isoschematron copying src\lxml\isoschematron\__init__.py -> build\lib.win-amd64-cpython-310\lxml\isoschematron copying src\lxml\etree.h -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\etree_api.h -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\lxml.etree.h -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\lxml.etree_api.h -> build\lib.win-amd64-cpython-310\lxml copying src\lxml\includes\c14n.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\config.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\dtdvalid.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\etreepublic.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\htmlparser.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\relaxng.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\schematron.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\tree.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\uri.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xinclude.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xmlerror.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xmlparser.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xmlschema.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xpath.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\xslt.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\__init__.pxd -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\etree_defs.h -> build\lib.win-amd64-cpython-310\lxml\includes copying src\lxml\includes\lxml-version.h -> build\lib.win-amd64-cpython-310\lxml\includes creating build\lib.win-amd64-cpython-310\lxml\isoschematron\resources creating build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\rng copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\rng creating build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl creating build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_skeleton_for_xslt1.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-cpython-310\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 running build_ext building 'lxml.etree' extension creating build\temp.win-amd64-cpython-310 creating build\temp.win-amd64-cpython-310\Release creating build\temp.win-amd64-cpython-310\Release\src creating build\temp.win-amd64-cpython-310\Release\src\lxml "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DCYTHON_CLINE_IN_TRACEBACK=0 -Isrc -Isrc\lxml\includes -IC:\Python\Python310\include -IC:\Python\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" /Tcsrc\lxml\etree.c /Fobuild\temp.win-amd64-cpython-310\Release\src\lxml\etree.obj -w cl: 命令行 warning D9025 :正在重写“/W3”(用“/w”) etree.c C:\Users\qt-hp-ab2\AppData\Local\Temp\pip-install-_g8zrjmz\lxml_2c901d1810d74771b3a39307f0990c6d\src\lxml\includes/etree_defs.h(14): fatal error C1083: 无法打开包括文件: “libxml/xmlversion.h”: No such file or directory Compile failed: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 creating Users creating Users\QT-HP-~1 creating Users\QT-HP-~1\AppData creating Users\QT-HP-~1\AppData\Local creating Users\QT-HP-~1\AppData\Local\Temp "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -I/usr/include/libxml2 "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" /TcC:\Users\QT-HP-~1\AppData\Local\Temp\xmlXPathInits0_z6jhq.c /FoUsers\QT-HP-~1\AppData\Local\Temp\xmlXPathInits0_z6jhq.obj xmlXPathInits0_z6jhq.c C:\Users\QT-HP-~1\AppData\Local\Temp\xmlXPathInits0_z6jhq.c(1): fatal error C1083: 无法打开包括文件: “libxml/xpath.h”: No such file or directory ********************************************************************************* Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed? ********************************************************************************* error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for lxml Failed to build lxml ERROR: Could not build wheels for lxml, which is required to install pyproject.toml-based projects
网上的方法:https://blog.csdn.net/m0_73700676/article/details/134018581
复制 rc.exe 和 rcdll.dll 到 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86
未解决
四、
免责声明:本号所涉及内容仅供安全研究与教学使用,如出现其他风险,后果自负。
参考、来源:
https://blog.csdn.net/SSY_1992/article/details/132162056
https://blog.csdn.net/ViatorSun/article/details/118699938 (Microsoft Visual C++ Build Tools)
https://blog.csdn.net/qq_37553692/article/details/128996821 (Microsoft C++构建工具)
https://blog.csdn.net/qq_44319167/article/details/130439875
https://zhuanlan.zhihu.com/p/165008313
https://blog.csdn.net/xinhongjun12/article/details/90443119 (手动安装:pip install lxml‑4.3.3‑cp38‑cp38m‑win32.whl )
https://blog.csdn.net/sunnyrainflower/article/details/127640244 (安装了低版本的python==3.9.12就可以了,不用装任何插件就能顺利安装。)
https://blog.csdn.net/xinhongjun12/article/details/90443119
https://blog.csdn.net/m0_73700676/article/details/134015153
https://blog.csdn.net/m0_73700676/article/details/134018581
https://blog.csdn.net/kaever/article/details/106526610
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)