如何在 Ubuntu 上安装 lxml [英] How to install lxml on Ubuntu

查看:67
本文介绍了如何在 Ubuntu 上安装 lxml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 11 上使用 easy_install 安装 lxml 时遇到困难.

I'm having difficulty installing lxml with easy_install on Ubuntu 11.

当我输入 $easy_install lxml 我得到:

Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.3
Downloading http://lxml.de/files/lxml-2.3.tgz
Processing lxml-2.3.tgz
Running lxml-2.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-7UdQOZ/lxml-2.3/egg-dist-tmp-GacQGy
Building lxml version 2.3.
Building without Cython.
ERROR: /bin/sh: xslt-config: not found

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

Using build configuration of libxslt 
In file included from src/lxml/lxml.etree.c:227:0:
src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory
compilation terminated.

似乎没有安装libxsltlibxml2.我尝试按照 http://www.techsww.com 上的说明进行操作/tutorials/libraries/libxslt/installation/installing_libxslt_on_ubuntu_linux.phphttp://www.techsww.com/tutorials/libraries/libxml/installation/installing_libxml_on_ubuntu_linux.php 没有成功.

It seems that libxslt or libxml2 is not installed. I've tried following the instructions at http://www.techsww.com/tutorials/libraries/libxslt/installation/installing_libxslt_on_ubuntu_linux.php and http://www.techsww.com/tutorials/libraries/libxml/installation/installing_libxml_on_ubuntu_linux.php with no success.

如果我尝试 wget ftp://xmlsoft.org/libxml2/libxml2-sources-2.6.27.tar.gz 我得到

<successful connection info>
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /libxml2 ... done.
==> SIZE libxml2-sources-2.6.27.tar.gz ... done.
==> PASV ... done.    ==> RETR libxml2-sources-2.6.27.tar.gz ... 
No such file `libxml2-sources-2.6.27.tar.gz'.

如果我先尝试另一个,我将进入 ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2 和最终会失败:

If I try the other first, I'll get to ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2 and that will fail eventually with:

checking for libxml libraries >= 2.6.27... configure: error: Could not find libxml2 anywhere, check ftp://xmlsoft.org/.

我已经尝试了 libxml22.6.272.6.29 两个版本,没有任何区别.

I've tried both versions 2.6.27 and 2.6.29 of libxml2 with no difference.

不遗余力,我已经成功地完成了sudo apt-get install libxml2-dev,但这没有任何改变.

Leaving no stone unturned, I have successfully done sudo apt-get install libxml2-dev, but this changes nothing.

推荐答案

既然您使用的是 Ubuntu,请不要理会那些源包.只需使用 apt-get 安装这些开发包.

Since you're on Ubuntu, don't bother with those source packages. Just install those development packages using apt-get.

apt-get install libxml2-dev libxslt1-dev python-dev

如果您对可能较旧的 lxml 版本感到满意,您可以尝试

If you're happy with a possibly older version of lxml altogether though, you could try

apt-get install python-lxml

并完成它.:)

这篇关于如何在 Ubuntu 上安装 lxml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆