gpt4 book ai didi

python - 如何在 Windows 上安装 lxml

转载 作者:IT老高 更新时间:2023-10-28 20:44:42 24 4
gpt4 key购买 nike

我正在尝试在装有 Python 3.4 的 Windows 8.1 笔记本电脑上安装 lmxl,但失败得很惨。

首先,我尝试了简单明了的解决方案:pip install lxml。然而,这并没有奏效。它是这样说的:

Downloading/unpacking lxml
Running setup.py (path:C:\Users\CARTE_~1\AppData\Local\Temp\pip_build_carte_000\lxml\setup.py) egg_info for package lxml
Building lxml version 3.4.2.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)

warning: no previously-included files found matching '*.py'
Installing collected packages: lxml
Running setup.py install for lxml
Building lxml version 3.4.2.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
building 'lxml.etree' extension
C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
error: Unable to find vcvarsall.bat
Complete output from command C:\Python34\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\CARTE_~1\\AppData\\Local\\Temp\\pip_build_carte_000\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\CARTE_~1\AppData\Local\Temp\pip-l8vvrv9g-record\install-record.txt --single-version-externally-managed --compile:
Building lxml version 3.4.2.

Building without Cython.

ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"

** make sure the development packages of libxml2 and libxslt are installed **



Using build configuration of libxslt

running install

running build

running build_py

creating build

creating build\lib.win32-3.4

creating build\lib.win32-3.4\lxml

copying src\lxml\builder.py -> build\lib.win32-3.4\lxml

copying src\lxml\cssselect.py -> build\lib.win32-3.4\lxml

copying src\lxml\doctestcompare.py -> build\lib.win32-3.4\lxml

copying src\lxml\ElementInclude.py -> build\lib.win32-3.4\lxml

copying src\lxml\pyclasslookup.py -> build\lib.win32-3.4\lxml

copying src\lxml\sax.py -> build\lib.win32-3.4\lxml

copying src\lxml\usedoctest.py -> build\lib.win32-3.4\lxml

copying src\lxml\_elementpath.py -> build\lib.win32-3.4\lxml

copying src\lxml\__init__.py -> build\lib.win32-3.4\lxml

creating build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\__init__.py -> build\lib.win32-3.4\lxml\includes

creating build\lib.win32-3.4\lxml\html

copying src\lxml\html\builder.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\clean.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\defs.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\diff.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\ElementSoup.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\formfill.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\html5parser.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\soupparser.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\usedoctest.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\_diffcommand.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\_html5builder.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\_setmixin.py -> build\lib.win32-3.4\lxml\html

copying src\lxml\html\__init__.py -> build\lib.win32-3.4\lxml\html

creating build\lib.win32-3.4\lxml\isoschematron

copying src\lxml\isoschematron\__init__.py -> build\lib.win32-3.4\lxml\isoschematron

copying src\lxml\lxml.etree.h -> build\lib.win32-3.4\lxml

copying src\lxml\lxml.etree_api.h -> build\lib.win32-3.4\lxml

copying src\lxml\includes\c14n.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\config.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\dtdvalid.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\etreepublic.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\htmlparser.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\relaxng.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\schematron.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\tree.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\uri.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\xinclude.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\xmlerror.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\xmlparser.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\xmlschema.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\xpath.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\xslt.pxd -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\etree_defs.h -> build\lib.win32-3.4\lxml\includes

copying src\lxml\includes\lxml-version.h -> build\lib.win32-3.4\lxml\includes

creating build\lib.win32-3.4\lxml\isoschematron\resources

creating build\lib.win32-3.4\lxml\isoschematron\resources\rng

copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win32-3.4\lxml\isoschematron\resources\rng

creating build\lib.win32-3.4\lxml\isoschematron\resources\xsl

copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win32-3.4\lxml\isoschematron\resources\xsl

copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win32-3.4\lxml\isoschematron\resources\xsl

creating build\lib.win32-3.4\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win32-3.4\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win32-3.4\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win32-3.4\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_skeleton_for_xslt1.xsl -> build\lib.win32-3.4\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win32-3.4\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win32-3.4\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

running build_ext

building 'lxml.etree' extension

C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'

warnings.warn(msg)

error: Unable to find vcvarsall.bat

----------------------------------------
Cleaning up...
Command C:\Python34\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\CARTE_~1\\AppData\\Local\\Temp\\pip_build_carte_000\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\CARTE_~1\AppData\Local\Temp\pip-l8vvrv9g-record\install-record.txt --single-version-externally-managed --compile failed with error code 1 in C:\Users\CARTE_~1\AppData\Local\Temp\pip_build_carte_000\lxml
Storing debug log for failure in C:\Users\carte_000\pip\pip.log

然后我查看了这个名为 Internet 的伟大而有用的东西,很多人都有同样的错误,需要 libxml2libxlst。他们推荐了一个叫做 Christoph Gohlke 的人的页面,他为一堆包提供了某种二进制文件。你可以找到它here (quicklink to the lxml part)。

所以在我放弃尝试为 pip 寻找 libxml2 和 libxslt 之后,我决定去那里,并发现 绝对吨 的下载。我知道我需要一个 64 位的,但我不知道我需要哪个“cp”。

因此,无论是在 pip 方法或 Gohlke 索引方法上给我一个解决方案的答案都会很棒。

最佳答案

或者你也可以去Christoph's Gohlke's Python page然后下载正确的 lxml 文件。 (一般因为我用的是python 3.4,而且我有windows,所以我下载的是lxml-3.4.4-cp34-none-win32.whl)

转到它所在的文件夹。在后台单击(因此未选择任何内容),然后同时左移 + 右键单击​​并单击打开命令窗口。然后输入C:/Python34/Scripts/pip install "NAME OF THE FILE YOU Just DOWNLOADED.whl"

在这种情况下,它将是 C:/Python34/Scripts/pip install "lxml-3.4.4-cp34-none-win32.whl"

现在按回车键。这对我来说效果很好,在你输入报价后,你也可以按 Tab,它应该会为你填写正确的。

关于python - 如何在 Windows 上安装 lxml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29440482/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com