【问题标题】:easy_install lxml on Python 2.7 on WindowsWindows 上 Python 2.7 上的 easy_install lxml
【发布时间】:2012-03-16 06:35:36
【问题描述】:

我在 Windows 上使用 python 2.7。当我尝试使用[setuptools][2] 的easy_install 安装[lxml][1] 时,为什么会出现以下错误?

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

【问题讨论】:

  • 尝试从 Visual Studio 命令提示符运行
  • 我可以从here 下载安装程序,该程序有效,但是我仍然想知道为什么常规方法不起作用...
  • 我已经安装了 VS10,但是当我能够easy_install 没有它的许多其他软件包时,我为什么需要它用于 lxml,例如:django、pytz、mock、South 等...

标签: python lxml python-2.7 setuptools easy-install


【解决方案1】:

lxml >= 3.x.x

  1. 下载 MS Windows Installer 软件包之一
  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 没有 Windows 二进制 Egg(2.3.0 是 2.x.x 的最新版本)。
不提供版本号 easy_install 将下载最新的源代码,
但是你没有安装 libxml2 和 libxslt。

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

【讨论】:

  • 我在 virtualenv 中安装 lxml 2.3.3 失败
  • 这个在 conda 中的安装在过去的三天里让我很生气!这是最终对我有用的解决方案。
【解决方案2】:

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

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

这是win32中最简单的方法。

【讨论】:

  • 它不能直接用于 virtualenv。因此,将 virtualenv 中的 easy_install 与下载的二进制安装程序一起使用以使其正常工作。即easy_install "c:/lxml_installer.exe"(编辑。我讨厌必须在Windows 上执行此操作,但这是我找到的最简单的方法。它也可以从URL 工作,但是页面上的二进制文件没有直接文件链接这个答案)
【解决方案3】:

我遇到了同样的问题。我不知道 vcvarsall.bat 问题,但如果您只想安装 lxml,您可以在此处使用图形安装程序:

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

这对我有用。

【讨论】:

    【解决方案4】:

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

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

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

    【讨论】:

    • 是的,这是唯一对我有用的东西。完美!
    【解决方案5】:

    您也可以使用 anaconda。一旦你安装了它 (http://continuum.io/downloads),你就可以运行 conda install lxml 来安装 lxml。

    【讨论】:

      猜你喜欢
      • 2011-03-04
      • 2012-08-30
      • 2012-06-30
      • 2013-12-25
      • 1970-01-01
      • 2012-03-06
      • 1970-01-01
      • 2016-04-26
      • 1970-01-01
      相关资源
      最近更新 更多