Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: problem with mod_python

Reply
Thread Tools

Re: problem with mod_python

 
 
Joshua Kugler
Guest
Posts: n/a
 
      02-19-2008
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

 
Reply With Quote
 
 
 
 
Graham Dumpleton
Guest
Posts: n/a
 
      02-20-2008
On Feb 20, 6:04 am, Joshua Kugler <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mod_python.so is garbled mod_python.so is garbled blbmdsmith Python 1 12-14-2006 12:15 AM
MySQLdb problem with mod_python, please help ws Wang Python 2 11-30-2004 08:40 PM
mod_python problem Gandalf Python 3 05-07-2004 11:38 AM
Problem with mod_python and 4Suite Doug Farrell Python 2 08-12-2003 12:21 PM
Mod_python xml parsing problem Mike Medland Python 0 07-01-2003 08:08 AM



Advertisments