简体   繁体   English

在RHEL for Python 2.7上安装lxml

[英]Installing lxml on RHEL for Python 2.7

So the RHEL machine originally had Python 2.4. 因此,RHEL机器最初具有Python 2.4。 I installed Python 2.7. 我安装了Python 2.7。 I want to install lxml module and I cannot use pip or setup tools due to proxy concerns. 我想安装lxml模块,由于代理问题,我无法使用pip或设置工具。 I used 我用了

sudo yum install python-lxml 须藤百胜安装python-lxml

It installed lxml for Python 2.4 which is the default. 它为Python 2.4安装了lxml,这是默认设置。 How can I make the install for the 2.7 version. 如何安装2.7版本。

The short answer is, not easily. 简短的答案是,不容易。 I'm assuming you're using RHEL5 since you mentioned python 2.4 was in the repo. 我假设您正在使用RHEL5,因为您在存储库中提到了python 2.4。 The problem is that lxml is not a pure python library, it is a rather thin wrapper around two C/C++ libraries, libxml2 and libxslt. 问题在于lxml并不是一个纯python库,它是围绕两个C / C ++库libxml2和libxslt的相当薄的包装。 This means that any RPM installer you find for python-lxml or any attempt to build python-lxml from source is going to require you to have those two libraries installed. 这意味着您为python-lxml找到的任何RPM安装程序,或从源代码构建python-lxml的任何尝试都将要求您安装这两个库。

To make matters worse, python-lxml requires 2.7 or greater of libxml and 1.1.23 of libxslt. 更糟糕的是,python-lxml需要2.7或更高版本的libxml和1.1.23的libxslt。 RHEL5 supports libxml 2.6 and libxslt 1.1.17. RHEL5支持libxml 2.6和libxslt 1.1.17。 This means you won't be able to find any standard RHEL5 RPMs for installing the proper versions of those two libraries as any RPM for greater versions will probably depend on greater versions of other things. 这意味着您将无法找到用于安装这两个库的正确版本的任何标准RHEL5 RPM,因为更高版本的任何RPM都可能依赖于其他版本的更高版本。 For example, the libxml2 2.7 RPM that ships with RHEL6 requires GLIBC 2.7 and RHEL5 has GLIBC 2.6. 例如,RHEL6随附的libxml2 2.7 RPM需要GLIBC 2.7,而RHEL5具有GLIBC 2.6。

However, it appears you can probably install libxml2 and libxslt from source fairly easily as explained here . 但是,您似乎可以从这里很容易地从源代码安装libxml2和libxslt,如此处所述 Once you've done that it should be straightforward to build python-lxml from source following the directions on the site. 一旦完成,按照站点上的指示从源代码构建python-lxml应该很简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM