2012-02-26 101 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