WebFaction
Community site: login faq

I needed to do install the lxml library under python2.5 on an older machine running Centos 4. See below for details on how to go about doing this.

asked 14 Sep '12, 11:07

houdinihound
3627
accept rate: 66%

edited 14 Sep '12, 11:15


After trying and failing numerous other methods to install lxml under python2.5 on a centos4 machine, I received this answer from Sean F. at Webfaction, which worked perfectly.

CentOS4 is a rather old operating system, so it's tricky to build newer software on it. In this case, you can't use STATIC_DEPS=true, since it pulls in a version of libxml2 that will not build on CentOS4.

Instead, you need to build everything manually. You can do so with the following commands:

# begin
mkdir -p ~/tmp ~/src ~/lib/python2.5
export TMPDIR=~/tmp
export PATH=$HOME/bin:$PATH
export CPPFLAGS="-I$HOME/include $CPPFLAGS"
export LDFLAGS="-L$HOME/lib $LDFLAGS"
cd src
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz
tar zxf libxml2-2.7.8.tar.gz
cd libxml2-2.7.8
./configure --prefix=$HOME  --with-python=python2.5
make
make install
cd ..
wget ftp://xmlsoft.org/libxslt/libxslt-1.1.27.tar.gz
tar zxf libxslt-1.1.27.tar.gz 
cd libxslt-1.1.27
/configure --prefix=$HOME --with-libxml-prefix=$HOME  --with-python=python2.5
make
make install
cd ~
cat > ~/.pydistutils.cfg << EOF
[build_ext]
include_dirs=$HOME/include
library_dirs=$HOME/lib
EOF
easy_install-2.5 lxml==2.3.4
echo "export LD_LIBRARY_PATH=$HOME/lib" >> ~/.bashrc
export LD_LIBRARY_PATH=$HOME/lib
# end

Now when running python2.5 one can import lxml. For different versions of python change the --with-python= bit in the two places above.

permanent link

answered 14 Sep '12, 11:12

houdinihound
3627
accept rate: 66%

edited 14 Sep '12, 11:13

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×337
×9
×1

question asked: 14 Sep '12, 11:07

question was seen: 8,129 times

last updated: 14 Sep '12, 11:15

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM