Re: problem with mod_python

Discussion in 'Python' started by Joshua Kugler, Feb 19, 2008.

  1. 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
    Joshua Kugler, Feb 19, 2008
    #1
    1. Advertising

  2. On Feb 20, 6:04 am, Joshua Kugler <> 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
    Graham Dumpleton, Feb 20, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Medland

    Mod_python xml parsing problem

    Mike Medland, Jul 1, 2003, in forum: Python
    Replies:
    0
    Views:
    374
    Mike Medland
    Jul 1, 2003
  2. Doug Farrell

    Problem with mod_python and 4Suite

    Doug Farrell, Aug 8, 2003, in forum: Python
    Replies:
    2
    Views:
    333
    Doug Farrell
    Aug 12, 2003
  3. Gandalf

    mod_python problem

    Gandalf, May 6, 2004, in forum: Python
    Replies:
    3
    Views:
    1,500
    Gandalf
    May 7, 2004
  4. ws Wang
    Replies:
    2
    Views:
    486
    ws Wang
    Nov 30, 2004
  5. blbmdsmith
    Replies:
    1
    Views:
    634
    Graham Dumpleton
    Dec 14, 2006
Loading...

Share This Page