[mod_python] Installation problems with mod_python

Ben Thompson ben at kilgore.demon.co.uk
Wed May 9 06:18:12 EDT 2007


Hi,

 

First-time user of this mailing-list and apache/python here. Please be
gentle with me :-)

 

Problem: When I point my browser at a file with the extension .py, the
browser displays the contents of the file rather than the results of running
it. Apache and python both seem to run ok. I have checked FAQs/How
Tos/Getting Started guides but without success.

 

Platform: Windows XP Professional Version 2002 Service Pack 2

 

Here are the relevant lines from httpd.conf:

 

# Python

LoadModule python_module modules/mod_python.so

 

# Python

<Directory E:/Projects/Web/Home/htdocs/test> 

        AddHandler mod_python .py

        PythonHandler mptest 

        PythonDebug On 

</Directory>

<Location /mpinfo>

      SetHandler mod_python

      PythonHandler mod_python.testhandler

</Location>

<Directory E:/Projects/Web/Home/htdocs/test>

AllowOverride FileInfo

</Directory>

 

The mpinfo location directive seems to work. Here is the Apache version line
from http://localhost/mpinfo:

 

Apache/2.2.4 (Win32) mod_python/3.3.1 Python/2.5.1 PHP/5.2.1

 

But I see no sign of mod_python being loaded successfully in logs/error.log.
Here is what happens when I restart the server:

 

[Sun May 06 23:55:49 2007] [notice] Parent: Received shutdown signal --
Shutting down the server.

[Sun May 06 23:55:49 2007] [notice] Child 2192: Exit event signaled. Child
process is ending.

[Sun May 06 23:55:50 2007] [notice] Child 2192: Released the start mutex

[Sun May 06 23:55:51 2007] [notice] Child 2192: Waiting for 250 worker
threads to exit.

[Sun May 06 23:55:51 2007] [notice] Child 2192: All worker threads have
exited.

[Sun May 06 23:55:51 2007] [notice] Child 2192: Child process is exiting

[Sun May 06 23:55:51 2007] [notice] Parent: Child process exited
successfully.

[Sun May 06 23:55:56 2007] [notice] Apache/2.2.4 (Win32) PHP/5.2.1
configured -- resuming normal operations

[Sun May 06 23:55:56 2007] [notice] Server built: Jan  9 2007 23:17:20

[Sun May 06 23:55:56 2007] [notice] Parent: Created child process 1904

[Sun May 06 23:55:56 2007] [error] python_init: Python version mismatch,
expected '2.5', found '2.5.1'.

[Sun May 06 23:55:56 2007] [error] python_init: Python executable found
'E:\\Program Files\\Apache Software Foundation\\Apache2.2\\bin\\httpd.exe'.

[Sun May 06 23:55:56 2007] [error] python_init: Python path being used
'C:\\WINDOWS\\system32\\python25.zip;E:\\Python25\\Lib;E:\\Python25\\DLLs;E:
\\Python25\\Lib\\lib-tk;;E:\\Program Files\\Apache Software
Foundation\\Apache2.2\\bin'.

[Sun May 06 23:55:56 2007] [notice] mod_python: Creating 8 session mutexes
based on 0 max processes and 250 max threads.

PHP Warning:  Module 'mysql' already loaded in Unknown on line 0

[Sun May 06 23:55:56 2007] [notice] Child 1904: Child process is running

[Sun May 06 23:55:56 2007] [notice] Child 1904: Acquired the start mutex.

[Sun May 06 23:55:56 2007] [notice] Child 1904: Starting 250 worker threads.

[Sun May 06 23:55:56 2007] [notice] Child 1904: Starting thread to listen on
port 80.

 

At one point I read a suggestion to create a .htaccess file in my test
directory (:/Projects/Web/Home/htdocs/test) but on Windows you can't name a
file ".htaccess" so I guess that the right thing to do was to call it
"htaccess" with no extension. E:/Projects/Web/Home/htdocs/test/htaccess
contains:

 

AddHandler mod_python .py

PythonHandler mptest

PythonDebug On

 

and E:/Projects/Web/Home/htdocs/test/mptest.py contains

 

from mod_python import apache

 

def handler(req):

            req.log_error('handler')

            req.content_type = 'text/plain'

            req.send_http_header()

            return apache.OK

 

I note that if I run this from the command prompt I get:

 

Traceback (most recent call last):

  File "mptest.py", line 1, in <module>

    from mod_python import apache

  File "E:\Python25\Lib\site-packages\mod_python\apache.py", line 30, in
<module>

    import _apache

ImportError: No module named _apache

 

 

I can't quite put together all the evidence to sort this out. Any help
gratefully received.

 

Ben

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20070509/a4d7c7cc/attachment-0001.html


More information about the Mod_python mailing list