Regarding the lxml import error only in a web-request
stefan_ml at behnel.de
Fri Mar 20 17:14:47 CET 2009
> I'm trying to run Django from Apache using FastCGI in a shared hosting
> environment on DH. I've installed python 2.5.2 onto my home
> environment. And all the necessary libraries including lxml 2.1.3,
> libxml2, libxslt, flup, etc.
> I'm facing a strange issue with lxml, which occurs only when it is
> used from the webrequests. I'm getting the following error:
> Exception Type: ImportError
> Exception Value: ~/opt/lib/python2.5/site-packages/lxml-2.1.3-
> py2.5-linux-x86_64.egg/lxml/etree.so: undefined
> it basically comes when i'm trying to do this in my Django views.py
> from lxml import etree
> But the same is running perfectly well in my python console. Even with
> the following command it works well
> python -c "from lxml import etree"
> I've almost checked every installation and library paths.. not able to
> figure out what exactly would be the issue.
You most likely have an (older) system library of libxml2 and/or libxslt
installed. Try to use those *instead* of installing libxml2/libxslt
separately, or build lxml with the "--auto-rpath" option to make it
remember the path where the libraries were installed when it was compiled.
BTW, you do not need the Python bindings for those two libraries installed,
in case you are confusing the libxml2/libxslt Python modules with the
libxml2/libxslt libraries (which happens quite often).
More information about the Python-list