[mod_python] mod_python configuration problem?

Graham Dumpleton grahamd at dscpl.com.au
Sat Dec 3 00:04:36 EST 2005

On 03/12/2005, at 4:58 AM, chase3 at llnl.gov wrote:

> Hi,
> I am trying new to mod-python and have only light knowledge of
> CGI scripting.  A CGI script written by someone else is too slow,
> and I want to try converting it to mod_python.
> Looking at Graham's "Getting mod_python Working" doc, I think
> mod_python is installed at version 2.7 because I get the
> message:
>    "ImportError: No module named psp."
> The sys admin told me that mod_python is built into apache, so no  
> need to
> load it.  Our local Apache server is at 2.0.46.  Earlier he gave me
> this version info on Python products: python 2.2.35 and
> mod_python-3.0.3-3.ent
> (We are only approved to run enterprise 3.x and apache 2.x.)
> uname -a shows: Linux ... 2.4.21-20.ELsmp #1 SMP ... i686 i686 i386
> Gnu/Linux

Your admin may be correct. My document tends to ignore 3.0.X
versions. A quick check of documentation for 3.0.X suggests that
it doesn't have PSP module either.

> I put the following mptest.py:
>    from mod_python import apache
>    def handler ( req ):
>       req.content_type = "text/plain"
>       req.send_http_header()
>       req.write ( "Hello modtest" )
>       return apache.OK
> with .htaccess:
>    <Directory /usr/web/cgi-bin/tracker/modtest>
>    AddHandler mod_python .py
>    PythonHandler mptest
>    PythonDebug On
>    </Directory>

For a .htaccess file, you shouldn't have <Directory> directive.

> and pointed to URL:
> https://bugzi.llnl.gov/cgi-bin/tracker/modtest/mptest.py
> I got an Internal server error and found out that it was due to an
> import error:
> from mod_python import apache
> File
> "/usr/src/build/345626-i386/install/usr/lib/lib/python2.2/site- 
> packages/mod
> _python/apache.py line 67 in ?
> Import Error: No module named _apache
> I also get a Premature end of script.
> Another posting suggested that my problem is because mptest.py is  
> being
> run as a CGI script.  However, if I put the test in my home space, my
> browser is not able to get find it.

I would tend to agree that this looks like it is being executed as
a CGI.

> Any suggestions that would be helpful to getting the initial test  
> to work
> would be appreciated.

Put a syntax error in your .htaccess file. Ie., add a line consisting of
"XXX" by itself. If the .htaccess file is actually being consulted, you
should now get a 500 error due to the syntax error.

If no 500 error, then Apache is probably configured not to allow use of
.htaccess files in that part of the document tree and as a result, the
higher level CGI definitions are taking precedence.


More information about the Mod_python mailing list