[mod_python] RE: make_obcallback: could not import mod_python.apache

Terry MacDonald terry.macdonald at dsl.pipex.com
Thu Jan 29 18:42:26 EST 2004


On Thu, 2004-01-29 at 17:00, mod_python-request at modpython.org wrote:

> I'm getting the following error in the apache err_logs when I try to run the
> mptest.py script:
> [Wed Jan 28 14:55:14 2004] [error] make_obcallback: could not import
> mod_python.apache.
> 
> My Google searches have turned up quite a few people that have gotten the
> same error, but I still haven't found a fix for the problem.  Any help would
> be appreciated.  My latest attempts used mod_python 3.1.3b.  I got the same
> error using mod_python 3.0.4.  Here is what I've done so far.
> 
> 
> Compiled, installed, and tested Apache 2.0.48
> ./configure --prefix=/usr/local/apache2
> make
> make install
> 
> Compiled, installed, and tested Python 2.2.3
> ./configure -prefix=/usr/local/python2.2.3
> make
> make install
> 
> Compiled and Installed DSO for Mod_Python
> ./configure --with-apxs=/usr/local/apache2/bin/apxs
> --with-python=/usr/local/python2.2.3/bin/python2.2
> make
> make install
> 
> 
> Configured httpd.conf by adding the following:
> LoadModule python_module /usr/local/apache2/modules/mod_python.so
> 
> <Directory /usr/local/apache2/htdocs/test>
>   AddHandler python-program .py
>   PythonHandler mptest
>   PythonDebug On
> </Directory>
> 
> Created /usr/local/apache2/htdocs/test/mptest.py and set world execute
> from mod_python import apache
> 
> def handler(req):
>     req.write("Hello World!")
>     return apache.OK
> 
> 
> Apache Error Log After Startup
> [Wed Jan 28 14:55:14 2004] [notice] Apache/2.0.48 (Unix) mod_python/3.1.2b
> Python/2.2.3 configured -- resuming normal operations
> 
> Apache Error Log after http://servername/test/mptest.py is called
> [Wed Jan 28 14:55:14 2004] [notice] Apache/2.0.48 (Unix) mod_python/3.1.2b
> Python/2.2.3 configured -- resuming normal operations
> [Wed Jan 28 14:55:14 2004] [error] make_obcallback: could not import
> mod_python.apache.
> 

Does adding the following to the Apache config help:

    PythonPath "['/usr/local/apache2/htdocs/test']+sys.path"

Place it in the Directory directive.

This is not documented (probably should be especially for newbies as I
was!) but after a lot of headaches and experimenting it got my
implementation to work. It appears mod_python/python needs to be told
informed of every directory a python scripts frequent.

cheers

-- 
Terry
www.taumu.com



More information about the Mod_python mailing list