login community 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 Sep 14 '12 at 11:07

houdinihound's gravatar image

houdinihound
364

edited Sep 14 '12 at 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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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.

answered Sep 14 '12 at 11:12

houdinihound's gravatar image

houdinihound
364

edited Sep 14 '12 at 11:13

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
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

Tags:

×228
×7
×1

Asked: Sep 14 '12 at 11:07

Seen: 416 times

Last updated: Sep 14 '12 at 11:15

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited