我正试图用Python 3.4在我的Windows 8.1笔记本电脑上安装lmxl,但失败惨重.

首先,我try 了简单而明显的解决方案: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

然后我看了一个叫做The Internet的伟大而有用的东西,很多人都有同样的错误,需要libxml2libxlst.他们推荐一个叫Christoph Gohlke's page的人,他在那里为一堆软件包提供某种二进制内容.你可以找到here(quicklink to the lxml part).

所以在我放弃为pip寻找libxml2和libxslt之后,我决定go 那里,找到了an absolute ton个下载.我知道我需要一个64位的,但我不知道我需要哪个"cp".

所以,给我一个关于pip法或Gohlke指数法的解决方案会很好.

推荐答案

首先,在 comments 之后,我下载了lxml-3.4.2-cp34-none-win_amd64.whl文件,并试图用pip install打开它,但它只是告诉我,在我的系统上它不是一个有效的轮子文件或其他东西.

然后,我下载了win_32文件,它成功了!也许是因为我有一个英特尔处理器,AMD64只适用于AMD处理器,这并不奇怪.

Python-3.x相关问答推荐

CONNEXION.EXCEPTIONS.ResolverError:运行pyz文件时未命名模块

具有多个值的极轴旋转和熔化/取消旋转(反转旋转)操作(Pandas 堆叠/取消堆叠交替/UDF覆盖)

将数据帧扩展为矩阵索引

Django 3.2/Django-cms 3.11:查找错误:型号帐户.客户用户未注册

在BaseHTTPRequestHandler中填充和返回列表

无法导入名称';核心';来自部分初始化的模块';tensorflow_datasets';(很可能是由于循环导入)

如何在当前测试中使用fixture 转换后的数据进行参数化?

Python 列表求和所有出现的保留顺序

Pygame 错误地渲染等距图像

在不使用字符串方法的情况下查找字符串最后一个单词的长度 - Python

正则表达式:匹配字符串中的分隔符(字母和特殊字符)以形成新的子字符串

BeautifulSoup 和 pd.read_html - 如何将链接保存到最终数据框中的单独列中?

删除重复项,但将值相加为一

pip install mysqlclient 失败为 mysqlclient 运行 setup.py bdist_wheel ... 错误

两个字符串之间的正则表达式匹配?

在 Python 3.5 中使用 aiohttp 获取多个 url

在 Ubuntu 上为 Python3 安装 mod_wsgi

Python 3 中的连接列表

带有 Emacs 的 Python 3

调用 Python doctest 时如何启用省略号?