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
36●4