简体   繁体   中英

Installing lxml on RHEL for Python 2.7

So the RHEL machine originally had Python 2.4. I installed Python 2.7. I want to install lxml module and I cannot use pip or setup tools due to proxy concerns. I used

sudo yum install python-lxml

It installed lxml for Python 2.4 which is the default. How can I make the install for the 2.7 version.

The short answer is, not easily. I'm assuming you're using RHEL5 since you mentioned python 2.4 was in the repo. 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. 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.

To make matters worse, python-lxml requires 2.7 or greater of libxml and 1.1.23 of libxslt. RHEL5 supports libxml 2.6 and 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. For example, the libxml2 2.7 RPM that ships with RHEL6 requires GLIBC 2.7 and RHEL5 has GLIBC 2.6.

However, it appears you can probably install libxml2 and libxslt from source fairly easily as explained here . Once you've done that it should be straightforward to build python-lxml from source following the directions on the site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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