[mod_python] apache2 won't load mod_python (still)

Graham Dumpleton grahamd at dscpl.com.au
Tue Mar 22 19:49:19 EST 2005


Graham Dumpleton wrote ..
> Note how it calls PyErr_Print() to dump out the actual Python error which
> caused the import to fail. This isn't displaying in the log though because
> it is logging through the Apache logging API.

s/it is logging/it is not logging/  :-(

> Anyway, try and find the error messages which PyErr_Print() is generating.
> 
> I'll have some code changes you can make to mod_python.c soon as well
> to help track down whether the search path used by Python is correct.

Also try the following.

Manually edit your site-packages/mod_python/apache.py file and change
where the imports are to read:

import sys
sys.stderr.write("importing mod_python.apache\n")
import traceback
import time
import os
import pdb
import stat
import imp
import types
import _apache
sys.stderr.write("imported _apache\n")

If you can't find where the stderr messages are getting flushed to, use
something like the following instead.

mylog = open("/tmp/mp.log","w")
mylog.write("importing mod_python.apache\n")

import sys

import traceback
import time
import os
import pdb
import stat
import imp
import types
import _apache

mylog.write("imported _apache\n")
mylog.close()

If after doing the latter and restarting Apache, you can not find
any /tmp/mp.log file, it simply means that Python when executing
under Apache isn't even looking in your site-packages directory
where you think it should.

At that point, try setting PYTHONHOME explicitly as mentioned in
FAQ entry I referenced in previous mail.

    export PYTHONHOME='/home/httpd/python'
    httpd -X 2>error_log

I am not sure what you are mean't to set PYTHONHOME to, so you
might have to play and read documentation about what it does.
I think that it might need to be "/usr/local" for your installation.

Graham


More information about the Mod_python mailing list