[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 \
    --with-python=$FGS_DEV_HOME/built/python/bin/python

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>
  File 
"/home/nsavard/fgspython/lib/python2.6/site-packages/mod_python/apache.py", 
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.

Thanks.

Norm

-------------------------------
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
export PYTHON_VERSION=2.6
export PYTHONHOME=$FGS_HOME/bin
 
# 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:
$FGS_HOME/lib/python${PYTHON_VERSION}/lib-dynload:
$FGS_HOME/lib/python${PYTHON_VERSION}:
$FGS_HOME/lib/python${PYTHON_VERSION}/site-packages:


-----------------------
python.conf:
PassEnv PYTHONPATH
PassEnv PYTHONHOME

---------------------------------
mod_python.conf:
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
</Directory>
-------------------------------------------------
mptest.py:

from mod_python import apache

def handler(req):
    req.send_http_header()
    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 
mod_python.apache.\n
/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):
  File 
"/home/nsavard/fgspython/lib/python2.6/site-packages/mod_python/apache.py", 
line 22, in <module>
    import traceback
  File "/home/nsavard/fgspython/lib/python2.6/traceback.py", line 3, in 
<module>
    import linecache
  File "/home/nsavard/fgspython/lib/python2.6/linecache.py", line 9, in 
<module>
    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/lib-dynload', 
'/home/nsavard/fgspython/lib/python2.6', 
'/home/nsavard/fgspython/lib/python2.6/site-packages', '', 
'/home/nsavard/fgspython/bin/lib/python25.zip', 
'/home/nsavard/fgspython/bin/lib/python2.5/', 
'/home/nsavard/fgspython/bin/lib/python2.5/plat-linux2', 
'/home/nsavard/fgspython/bin/lib/python2.5/lib-tk', 
'/home/nsavard/fgspython/bin/lib/python2.5/lib-dynload']".
[Fri Jun 26 10:14:03 2009] [error] get_interpreter: no interpreter 
callback found.
[Fri Jun 26 10:14:03 2009] [error] [client 127.0.0.1] python_handler: 
Can't get/create interpreter.



More information about the Mod_python mailing list