problem with mod_python

Graham Dumpleton Graham.Dumpleton at gmail.com
Tue Feb 19 21:28:05 EST 2008


On Feb 20, 6:04 am, Joshua Kugler <jkug... at bigfoot.com> wrote:
> Pradnyesh Sawant wrote:
> > Hello,
> > I have a small program which does 'import hashlib'. This program runs fine
> > with python2.5. But when I try running the same program through
> > mod_python, I get the error: 'ImportError: No module named hashlib' in the
> > apache2 error.log
>
> > Searching online suggested me to include md5.so or md5module.so in
> > apache2. but I don't see that in a package for debian lenny (the system
> > I'm using).
>
> > So, my Q is, is it possible to make mod_python use the same PYTHONPATH as
> > the python2.5 interpreter? if so, how?
>
> It sounds like your mod_python may be compiled against a different version
> of Python than your main installation?  How did you install mod_python? How
> did you install your main python installation?
>
> What is the output of the command:
>
> ldd /path/to/mod_python.so
>
> (the full path on my system is /usr/lib/apache2/mod_python.so)
>
> There should be a line something like:
>
> libpython2.5.so.1.0 => /usr/lib/libpython2.5.so.1.0 (0xb7e37000)
>
> If it is pointing to libpython.2.4.so.1.0, then that could be the reason for
> you troubles.

The ldd trick only works if the Python version being used actually
supplied a shared library and mod_python was able to link against it,
otherwise a static version of Python is embedded in mod_python.

Some Linux distributions still possibly don't provide a shared library
for Python, or don't correctly symlink the .so into the Python config
directory along side the .a so that linkers will find it correctly
when -L for config directory is used. This has in part been the fault
of Python itself as build from source doesn't necessarily do that
symlink. Not sure if this has changed in more recent Python versions.

Graham




More information about the Python-list mailing list