无法在windows 11上安装lxml包


"PS D:Complete-Python-3-Bootcamp-master12-Advanced Python Modulespuzzle_unzip> pip install lxml
Collecting lxml
Using cached lxml-4.9.1.tar.gz (3.4 MB)
Preparing metadata (setup.py) ... done
Installing collected packages: lxml
DEPRECATION: lxml is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
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
╰─> [96 lines of output]
Building lxml version 4.9.1.
Building without Cython.
Building against pre-built libxml2 andl libxslt libraries
running install
C:UsersloharAppDataLocalProgramsPythonPython311Libsite-packagessetuptoolscommandinstall.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 buildlib.win-amd64-cpython-311
creating buildlib.win-amd64-cpython-311lxml
copying srclxmlbuilder.py -> buildlib.win-amd64-cpython-311lxml
copying srclxmlcssselect.py -> buildlib.win-amd64-cpython-311lxml
copying srclxmldoctestcompare.py -> buildlib.win-amd64-cpython-311lxml
copying srclxmlElementInclude.py -> buildlib.win-amd64-cpython-311lxml
copying srclxmlpyclasslookup.py -> buildlib.win-amd64-cpython-311lxml
copying srclxmlsax.py -> buildlib.win-amd64-cpython-311lxml
copying srclxmlusedoctest.py -> buildlib.win-amd64-cpython-311lxml
copying srclxml_elementpath.py -> buildlib.win-amd64-cpython-311lxml
copying srclxml__init__.py -> buildlib.win-amd64-cpython-311lxml
creating buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludes__init__.py -> buildlib.win-amd64-cpython-311lxmlincludes
creating buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtmlbuilder.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtmlclean.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtmldefs.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtmldiff.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtmlElementSoup.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtmlformfill.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtmlhtml5parser.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtmlsoupparser.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtmlusedoctest.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtml_diffcommand.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtml_html5builder.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtml_setmixin.py -> buildlib.win-amd64-cpython-311lxmlhtml
copying srclxmlhtml__init__.py -> buildlib.win-amd64-cpython-311lxmlhtml
creating buildlib.win-amd64-cpython-311lxmlisoschematron
copying srclxmlisoschematron__init__.py -> buildlib.win-amd64-cpython-311lxmlisoschematron
copying srclxmletree.h -> buildlib.win-amd64-cpython-311lxml
copying srclxmletree_api.h -> buildlib.win-amd64-cpython-311lxml
copying srclxmllxml.etree.h -> buildlib.win-amd64-cpython-311lxml
copying srclxmllxml.etree_api.h -> buildlib.win-amd64-cpython-311lxml
copying srclxmlincludesc14n.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesconfig.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesdtdvalid.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesetreepublic.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludeshtmlparser.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesrelaxng.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesschematron.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludestree.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesuri.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesxinclude.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesxmlerror.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesxmlparser.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesxmlschema.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesxpath.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesxslt.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludes__init__.pxd -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludesetree_defs.h -> buildlib.win-amd64-cpython-311lxmlincludes
copying srclxmlincludeslxml-version.h -> buildlib.win-amd64-cpython-311lxmlincludes
creating buildlib.win-amd64-cpython-311lxmlisoschematronresources
creating buildlib.win-amd64-cpython-311lxmlisoschematronresourcesrng
copying srclxmlisoschematronresourcesrngiso-schematron.rng -> buildlib.win-amd64-cpython-311lxmlisoschematronresourcesrng
creating buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsl
copying srclxmlisoschematronresourcesxslRNG2Schtrn.xsl -> buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsl
copying srclxmlisoschematronresourcesxslXSD2Schtrn.xsl -> buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsl
creating buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsliso-schematron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_abstract_expand.xsl -> buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsliso-schematron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_dsdl_include.xsl -> buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsliso-schematron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_schematron_message.xsl -> buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsliso-schematron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_schematron_skeleton_for_xslt1.xsl -> buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsliso-schematron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_svrl_for_xslt1.xsl -> buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsliso-schematron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1readme.txt -> buildlib.win-amd64-cpython-311lxmlisoschematronresourcesxsliso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating buildtemp.win-amd64-cpython-311
creating buildtemp.win-amd64-cpython-311Release
creating buildtemp.win-amd64-cpython-311Releasesrc
creating buildtemp.win-amd64-cpython-311Releasesrclxml
"C:Program Files (x86)Microsoft Visual Studio2022BuildToolsVCToolsMSVC14.34.31933binHostX86x64cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DCYTHON_CLINE_IN_TRACEBACK=0 -Isrc -Isrclxmlincludes -IC:UsersloharAppDataLocalProgramsPythonPython311include -IC:UsersloharAppDataLocalProgramsPythonPython311Include "-IC:Program Files (x86)Microsoft Visual Studio2022BuildToolsVCToolsMSVC14.34.31933include" "-IC:Program Files (x86)Microsoft Visual Studio2022BuildToolsVCAuxiliaryVSinclude" "-IC:Program Files (x86)Windows Kits10include10.0.22000.0ucrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\um" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\shared" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\winrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\cppwinrt" /Tcsrclxmletree.c /Fobuildtemp.win-amd64-cpython-311Releasesrclxmletree.obj -w
cl : Command line warning D9025 : overriding '/W3' with '/w'
etree.c
C:UsersloharAppDataLocalTemppip-install-v8_cypj7lxml_b1e7951ab83046e384fffcd4610d3736srclxmlincludes/etree_defs.h(14): fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': No such file or directory
Compile failed: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\HostX86\x64\cl.exe' failed with exit code 2
creating Users
creating Userslohar
creating UsersloharAppData
creating UsersloharAppDataLocal
creating UsersloharAppDataLocalTemp
"C:Program Files (x86)Microsoft Visual Studio2022BuildToolsVCToolsMSVC14.34.31933binHostX86x64cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -I/usr/include/libxml2 "-IC:Program Files (x86)Microsoft Visual Studio2022BuildToolsVCToolsMSVC14.34.31933include" "-IC:Program Files (x86)Microsoft Visual Studio2022BuildToolsVCAuxiliaryVSinclude" "-IC:Program Files (x86)Windows Kits10include10.0.22000.0ucrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\um" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\shared" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\winrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\cppwinrt" /TcC:UsersloharAppDataLocalTempxmlXPathInituop21067.c /FoUsersloharAppDataLocalTempxmlXPathInituop21067.obj
xmlXPathInituop21067.c
C:UsersloharAppDataLocalTempxmlXPathInituop21067.c(1): fatal error C1083: Cannot open include file: 'libxml/xpath.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\HostX86\x64\cl.exe' failed with exit code 2
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
[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.
╰─> lxml
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
PS D:Complete-Python-3-Bootcamp-master12-Advanced Python Modulespuzzle_unzip> "
  • 我正在尝试安装lxml库通过pip安装lxml。
  • 我还安装了vs build tools 2022 .
  • 之后,我卡住了这个错误,我尝试了很多东西,但他们不工作
  • 的东西,我尝试手动安装软件包。
  • 多种互联网解决方案

我希望在W11机器上安装lxml。我也使用vs code和pycharm python版本3.11和PIP版本22.3.1

Pythonlxml模块是两个C库的语言绑定/包装器。

对于Windows,他们提供了包含这些库的二进制版本。否则,在Windows上安装和运行它将是一种痛苦和折磨。因为这是Windows。"开发人员,开发人员,开发人员"……(正如lxml开发人员所说:"该平台的用户通常无法自己构建lxml")

通常情况下,当你通过pip安装时,你应该得到二进制发行版,但在这种情况下,你没有。

  1. 尝试固定旧版本,也许二进制文件可用:

    pip install lxml==4.9.0
    
  2. 尝试下载由Christoph Gohlke提供的lxml二进制发行版。

    你也可以通过pip安装wheel文件。

来源:

  1. 二进制版本在哪里?
  2. 源代码构建于MS Windows

最新更新