Scrapy安装 - lxml安装问题

时间:2016-08-08 04:26:25

标签: python scrapy lxml libxml2 failed-installation

我是Python的新手,我正在尝试安装scrapy,我在Windows 10上有python 2.7.12和pip 8.1.2。当我发出命令'pip install scrapy'时,它试图安装lxml并给出以下内容错误。我下载了libxml2二进制文件,解压缩到一个文件夹并在路径变量中添加了bin文件夹。但仍然是同样的问题。请指导我这个问题,我坚持这个。错误消息如下所述。

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:\\Users\\myuserid\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
creating users
creating users\myuser~1
creating users\myuser~1\appdata
creating users\myuser~1\appdata\local
creating users\myuser~1\appdata\local\temp
C:\Users\myuserid\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I/usr/include/libxml2 /Tcc:\users\myuser~1\appdata\local\temp\xmlXPathInita7i8_a.c /Fousers\myuser~1\appdata\local\temp\xmlXPathInita7i8_a.obj
xmlXPathInita7i8_a.c
c:\users\myuser~1\appdata\local\temp\xmlXPathInita7i8_a.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: command 'C:\\Users\\myuserid\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

----------------------------------------

Command "c:\softwares\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\myuser~1\\appdata\\local\\temp\\pip-build-m4bvsr\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\myuser~1\appdata\local\temp\pip-dnttln-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\myuser~1\appdata\local\temp\pip-build-m4bvsr\lxml\

3 个答案:

答案 0 :(得分:1)

您可以根据您的系统使用其中一个whl files

下载后,在下载该文件的位置使用以下命令:

pip install ***.whl

答案 1 :(得分:0)

Scrapy的docummentation recommends using Anaconda来安装软件包。 Lxml软件包在Windows上安装非常棘手,而anaconda是一个非常直接的快捷方式。

还有一些lxml mentioned in lxml's docummentation的非正式二进制文件可用于安装已编译的lxml软件包。还有更多的说明,如何在Windows OS上安装lxml。

答案 2 :(得分:0)

你有什么版本的pip? 只是升级pip有助于我的情况

pip install --upgrade pip