在Windows上安装libxml2及其Python绑定
我正在尝试安装libxml2,这样我就可以设置Python的绑定,最终使用lxml。
但是我搞不清楚应该在哪里解压这些文件。我在网上搜索也没有找到有效的信息。
我需要Cygwin或MinGW才能成功安装吗?
目前,我已经把libxml2.tar.gz和libxslt.tar.gz里的文件放在了Python文件夹的相应目录下。也就是说,压缩包里“include”文件夹下的文件现在在Python26\include\libxml2\libxml...等等。
但是当我运行easy_install lxml时,出现了以下输出:
Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.2.4
Downloading http://codespeak.net/lxml/lxml-2.2.4.tgz
Processing lxml-2.2.4.tgz
Running lxml-2.2.4\setup.py -q bdist_egg --dist-dir c:\users\rocco\appdata\local
\temp\easy_install-1xwbhy\lxml-2.2.4\egg-dist-tmp-9zwhe4
Building lxml version 2.2.4.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' need
s to be available.
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'
error: Setup script exited with error: Unable to find vcvarsall.bat
任何帮助都将非常有用,因为我已经尝试了一个多星期了 :(
谢谢
5 个回答
3
如果你在用 Python 2.5.x 版本,只需要输入 "easy_install lxml==2.2.2" 来安装就可以了。
34
最新版本的lxml(还有很多其他Python包)的Windows安装文件可以在这个网站找到:http://www.lfd.uci.edu/~gohlke/pythonlibs/
27
如果你没有特别的理由需要从源代码编译,直接使用已经编译好的lxml文件就可以了。