Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: problem with mod_python (http://www.velocityreviews.com/forums/t592783-re-problem-with-mod_python.html)

Joshua Kugler 02-19-2008 07:04 PM

Re: problem with mod_python
 
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.

Hope that helps.

j


Graham Dumpleton 02-20-2008 02:28 AM

Re: problem with mod_python
 
On Feb 20, 6:04 am, Joshua Kugler <jkug...@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



All times are GMT. The time now is 06:48 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.