2012-02-26 102 views
25

我在Windows上使用python 2.7。当我尝试使用[setuptools] [2]的easy_install安装[lxml] [1]时,如何发生以下错误?在Windows上的Python 2.7 easy_install lxml

C:\>easy_install lxml 
Searching for lxml 
Reading http://pypi.python.org/simple/lxml/ 
Reading http://codespeak.net/lxml 
Best match: lxml 2.3.3 
Downloading http://lxml.de/files/lxml-2.3.3.tgz 
Processing lxml-2.3.3.tgz 
Running lxml-2.3.3\setup.py -q bdist_egg --dist-dir c:\users\my_user\appdata\local\temp\easy_install-mtrdj2\lxml-2.3.3\egg-dist-tmp-tq8rx4 
Building lxml version 2.3.3. 
Building without Cython. 
ERROR: 'xslt-config' is not recognized as an internal or external command, 
operable program or batch file. 

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

Using build configuration of libxslt 
warning: no files found matching 'lxml.etree.c' under directory 'src\lxml' 
warning: no files found matching 'lxml.objectify.c' under directory 'src\lxml' 
warning: no files found matching 'lxml.etree.h' under directory 'src\lxml' 
warning: no files found matching 'lxml.etree_api.h' under directory 'src\lxml' 
warning: no files found matching 'etree_defs.h' under directory 'src\lxml' 
warning: no files found matching 'pubkey.asc' under directory 'doc' 
warning: no files found matching 'tagpython*.png' under directory 'doc' 
warning: no files found matching 'Makefile' under directory 'doc' 
error: Setup script exited with error: Unable to find vcvarsall.bat 

下载包并运行setup.py install也于事无补:

D:\My Documents\Installs\Dev\Python\lxml\lxml-2.3.3>setup.py install 
Building lxml version 2.3.3. 
Building without Cython. 
ERROR: 'xslt-config' is not recognized as an internal or external command, 
operable program or batch file. 

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

Using build configuration of libxslt 
running install 
running bdist_egg 
running egg_info 
writing src\lxml.egg-info\PKG-INFO 
writing top-level names to src\lxml.egg-info\top_level.txt 
writing dependency_links to src\lxml.egg-info\dependency_links.txt 
reading manifest file 'src\lxml.egg-info\SOURCES.txt' 
reading manifest template 'MANIFEST.in' 
warning: no files found matching 'lxml.etree.c' under directory 'src\lxml' 
warning: no files found matching 'lxml.objectify.c' under directory 'src\lxml' 
warning: no files found matching 'lxml.etree.h' under directory 'src\lxml' 
warning: no files found matching 'lxml.etree_api.h' under directory 'src\lxml' 
warning: no files found matching 'etree_defs.h' under directory 'src\lxml' 
warning: no files found matching 'pubkey.asc' under directory 'doc' 
warning: no files found matching 'tagpython*.png' under directory 'doc' 
warning: no files found matching 'Makefile' under directory 'doc' 
writing manifest file 'src\lxml.egg-info\SOURCES.txt' 
installing library code to build\bdist.win32\egg 
running install_lib 
running build_py 
creating build 
creating build\lib.win32-2.7 
creating build\lib.win32-2.7\lxml 
copying src\lxml\builder.py -> build\lib.win32-2.7\lxml 
copying src\lxml\cssselect.py -> build\lib.win32-2.7\lxml 
copying src\lxml\doctestcompare.py -> build\lib.win32-2.7\lxml 
copying src\lxml\ElementInclude.py -> build\lib.win32-2.7\lxml 
copying src\lxml\pyclasslookup.py -> build\lib.win32-2.7\lxml 
copying src\lxml\sax.py -> build\lib.win32-2.7\lxml 
copying src\lxml\usedoctest.py -> build\lib.win32-2.7\lxml 
copying src\lxml\_elementpath.py -> build\lib.win32-2.7\lxml 
copying src\lxml\__init__.py -> build\lib.win32-2.7\lxml 
creating build\lib.win32-2.7\lxml\html 
copying src\lxml\html\builder.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\clean.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\defs.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\diff.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\ElementSoup.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\formfill.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\html5parser.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\soupparser.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\usedoctest.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\_dictmixin.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\_diffcommand.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\_html5builder.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\_setmixin.py -> build\lib.win32-2.7\lxml\html 
copying src\lxml\html\__init__.py -> build\lib.win32-2.7\lxml\html 
creating build\lib.win32-2.7\lxml\isoschematron 
copying src\lxml\isoschematron\__init__.py -> build\lib.win32-2.7\lxml\isoschematron 
copying src\lxml\etreepublic.pxd -> build\lib.win32-2.7\lxml 
copying src\lxml\tree.pxd -> build\lib.win32-2.7\lxml 
copying src\lxml\etree_defs.h -> build\lib.win32-2.7\lxml 
creating build\lib.win32-2.7\lxml\isoschematron\resources 
creating build\lib.win32-2.7\lxml\isoschematron\resources\rng 
copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win32-2.7\lxml\isoschematron\resources\rng 
creating build\lib.win32-2.7\lxml\isoschematron\resources\xsl 
copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win32-2.7\lxml\isoschematron\resources\xsl 
copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win32-2.7\lxml\isoschematron\resources\xsl 
creating build\lib.win32-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win32-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win32-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win32-2.7\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-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win32-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win32-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 
running build_ext 
building 'lxml.etree' extension 
error: Unable to find vcvarsall.bat 

    [1]: http://lxml.de/ 
    [2]: http://pypi.python.org/pypi/setuptools 
+0

尝试从Visual Studio命令提示符运行 – 2012-02-26 14:44:38

+1

我能够从[这里](http://www.lfd.uci.edu/~gohlke/pythonlibs/)下载安装程序,但是我仍然喜欢要知道为什么常规方法不起作用... – Jonathan 2012-02-26 14:47:36

+0

你有C编译器吗? – reclosedev 2012-02-26 14:54:47

回答

45

LXML> = 3.xx的

  1. 下载的MS Windows安装程序包的一个
  2. easy_install "c:/lxml_installer.exe"(credit kobejohn)

MS Windows安装程序downloads available for lxml 3.3.5

一个list of all binary/egg lxml package downloads


LXML 2.3.x版本

没有窗户LXML 2.3.3二进制蛋(2.3.0从2.x.x最新的)。
未给出版本号easy_install将下载最新的源代码,
但您没有安装libxml2和libxslt。

,你可以安装缺少的库,或者你可以尝试的2.3,因为有适用于Windows二进制鸡蛋:
easy_install lxml==2.3

+1

[pypi.python.org lxml软件包列表](https://pypi.python.org/packages/2.7/l/lxml/) – 2014-05-21 00:36:15

+0

我在virtualenv上安装lxml 2.3.3失败 – 2016-08-11 17:56:44

+0

在过去的三天里,conda中的这个安装一直在杀我!这是最终为我工作的解决方案。 – RYS 2016-09-20 19:12:55

25

您可以下载非官方的Windows二进制文件在: http://www.lfd.uci.edu/~gohlke/pythonlibs/

例如for python 2.7 32bit: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

这是win32中最简单的方法。

+5

它不会直接为virtualenv工作。因此,使用下载的二进制安装程序从virtualenv中使用easy_install以使其工作。例如'easy_install“c:/lxml_installer.exe”(编辑,我讨厌使用Windows来做这件事,但这是我找到的最简单的方法,它也可以使用URL,但是没有直接的文件链接在这个答案的页面上的二进制文件) – KobeJohn 2013-01-04 09:13:27

10

我遇到了同样的问题。我不知道该vcvarsall.bat问题,但如果你只是想安装LXML您可以在这里使用图形安装程序:

https://pypi.python.org/pypi/lxml/3.2.3

为我工作。

1

提供了理想的解决方案(也适用于虚拟环境)here

基本上,它归结为从here(文件名中的“cp”代表您的Python版本)下载一个合适的轮盘文件,然后简单地将其加入。

它适用于Windows 7 64位上我的(virtualenv)Python3.3安装。

+0

是的,这是唯一适合我的东西。完善! – Pztar 2016-01-25 21:00:29