无法在Windows上安装lxml,致命错误C1083:无法打开包含文件:' libxml / xmlversion.h'

时间:2015-12-30 19:43:58

标签: python python-3.x scrapy lxml

Python noob,请耐心等待。我在www.python.org上使用了python installer for v3.5.1。我的意图是使用Scrapy来运行一些脚本。

pip install scrapy失败了,easy_install scrapy和其他人一样。我将错误跟踪到错误的lxml安装。这是错误日志。我甚至尝试过easy_installing libxml2,我不确定如何继续。

Building lxml version 3.5.0.
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
cl : Command line warning D9025 : overriding '/W3' with '/w'
lxml.etree.c
src\lxml\includes\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 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
xmlXPathInitck3f6zpk.c
C:\Users\Rohan\AppData\Local\Temp\easy_install-47utdost\lxml-3.5.0\temp\xmlXPathInitck3f6zpk.c(1): fatal error C1083: Cannot open include file: 'libxml/xpath.h': No such file or directory
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: Setup script exited with error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

2 个答案:

答案 0 :(得分:6)

我遇到了同样的问题,尽管使用的是WinPython 64bit 2.7.3.1。

我使用预编译的安装程序解决了它,可以在这里找到:https://pypi.python.org/pypi/lxml/3.3.3#downloads

通过运行.exe直接安装软件包失败,因为安装程序找不到我的python安装(尽管它已注册)。 但是,我成功使用WinPython控制面板来安装包!

编辑:在此之前,我尝试了我在stackoverflow上发现的各种东西,包括安装一些Visual C ++(Python)编译器,但没有一个工作。

答案 1 :(得分:2)

我在Windows 10上使用Python 64bit 2.7.11时遇到了同样的问题。

在我尝试使用pip多次安装scrapy后,我取得了如下成功:

  1. 首先我从lxml v3.6.0安装了预编译包.exe     文件。它可以在https://pypi.python.org/pypi/lxml/3.6.0找到。

  2. 最后,我再次运行pip install scrapy并安装结束     成功的。

  3. 快乐的黑客攻击!