1

I am using CentOS 6.5 and want to use newer versions of Python, lxml, libxml2 and libxslt2 than what's available from the repos.

So I build libxml2, libxslt2 and python 2.7.8 from scratch, and add all the binary paths to my $PATH. "xml2-config --cflags --libs" includes the correct (custom) locations of libxml libraries and includes.

I configure/make/make install python-2.7.8 to my home directory, add its bin to my path. Install setuptools by "python setup.py install", followed by easy_install pip.

Finally, pip install lxml ... This finds my correct locations of libxml.

However, 'from lxml import etree' fails because it expects my newer version of libxml but it looks at /usr/lib64/libxml and fails.

Why is it not detecting my libxml location? It detects it when installing lxml, but not when importing it?

ImportError: /usr/lib64/libxml2.so.2: version `LIBXML2_2.9.0' not found (required by /home/hsundara/packages_installed/python-2.7.8/lib/python2.7/site-packages/lxml/etree.so)

But when building -

Building against libxml2/libxslt in one of the following directories:

  /home/hsundara/packages_installed/libxslt-1.1.28/lib
  /home/hsundara/packages_installed/libxml2-2.9.1/lib

Any solutions?

1

You should be able to configure lxml to find your own version of libxml2 and libxslt using the --auto-rpath install option.

First, uninstall your current version of lxml.

pip uninstall lxml

Then, add xml2-config and xslt-config to your path.

export PATH=/home/hsundara/packages_installed/libxslt-1.1.28/bin:/home/hsundara/packages_installed/libxml2-2.9.1/bin:$PATH

Finally, install lxml passing in the auto-rpath install option:

pip install lxml --install-option="--auto-rpath"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.