[mod_python] mod_python installation on Ubuntu

Normand Savard nsavard at mapgears.com
Fri Jun 26 10:38:20 EDT 2009

I'm trying to make mod_python works in a non traditional environment, 
mainly in the FGS environment (http://www.maptools.org/fgs/).  I built 
the mod_python 3.3.1 with Apache 2.2.11.  The configure switches are:

./configure --prefix=$FGS_DEV_HOME/built/mod_python \
    --with-apxs=$FGS_DEV_HOME/built/apache/bin/apxs \

I have no .htaccess file.

When I run python on the command line and try and import mod_python, I got:

nsavard at Manie:~/fgspython$ python
Python 2.6.2 (r262:71600, May 25 2009, 17:09:05)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import mod_python.apache
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
line 30, in <module>
    import _apache
ImportError: No module named _apache

It means that mod_python is installed based on what I read on the 
mailing list.  If I access mptest.py through the browser, the script 
doesn't run and outputs the error that I pasted below.  I did read most 
of what I found on Google but still searching.

Does someone have any idea of what is happening?

The relevant information is pasted below.



OS information:

Thank you for your interest in Ubuntu 8.10
                - the Intrepid Ibex - released in October 2008.
Shell environment variables:
#Set python home variable
# Set python library search paths
# needed -> standard paths are hard-coded in interpreter to built directory
# add your module file working directories to the list as desired
export PYTHONPATH=$FGS_HOME/pymod:$FGS_HOME/bin:


LoadModule python_module libexec/mod_python.so

Alias /test "/home/nsavard/fgspython/www/htdocs/test"

<Directory /home/nsavard/fgspython/www/htdocs/test>
  AddHandler python-program .py
  PythonHandler mptest
  PythonDebug On

from mod_python import apache

def handler(req):
    req.write("Hello World!")
    return apache.OK

Here is the error_log output:

[Fri Jun 26 10:13:57 2009] [notice] mod_python: Creating 8 session 
mutexes based on 256 max processes and 0 max threads.
[Fri Jun 26 10:13:57 2009] [notice] mod_python: using mutex_directory /tmp
[Fri Jun 26 10:13:57 2009] [notice] Apache/2.2.11 (Unix) 
mod_python/3.3.1 Python/2.5.2 configured -- resuming normal operations
[Fri Jun 26 10:14:03 2009] [error] make_obcallback: could not import 
/home/nsavard/fgspython/lib/python2.6/site.py:150: Warning: 'with' will 
become a reserved keyword in Python 2.6
'import site' failed; use -v for traceback
/home/nsavard/fgspython/lib/python2.6/site.py:150: Warning: 'with' will 
become a reserved keyword in Python 2.6
'import site' failed; use -v for traceback
Traceback (most recent call last):
line 22, in <module>
    import traceback
  File "/home/nsavard/fgspython/lib/python2.6/traceback.py", line 3, in 
    import linecache
  File "/home/nsavard/fgspython/lib/python2.6/linecache.py", line 9, in 
    import os
  File "/home/nsavard/fgspython/lib/python2.6/os.py", line 757
    bs = b""
SyntaxError: invalid syntax
[Fri Jun 26 10:14:03 2009] [error] make_obcallback: Python path being 
used "['/home/nsavard/fgspython/pymod', '/home/nsavard/fgspython/bin', 
'/home/nsavard/fgspython/lib/python2.6/site-packages', '', 
[Fri Jun 26 10:14:03 2009] [error] get_interpreter: no interpreter 
callback found.
[Fri Jun 26 10:14:03 2009] [error] [client] python_handler: 
Can't get/create interpreter.

More information about the Mod_python mailing list