[mod_python] Troubles with mod_python and Apache for Win xp

Graham Dumpleton graham.dumpleton at gmail.com
Tue Mar 18 01:15:55 EDT 2008


On 18/03/2008, Joseph Sliz <jsliz at fluentenergy.com> wrote:
>
>
>
>
> I am new to mod_python and Apache.
>
>   My environment is:
>
> Windows XP Prof sp2
> Python 2.4
> Apache 2.2.8
> Mod_python 3.3.1
>
> I've already added the following to the Apache httpd.conf
>
> LoadFile "c:/python24/python24.dll"
> LoadFile "c:/python24/msvcr71.dll"
> LoadFile "c:/python24/msvcp71.dll"
> LoadModule python_module modules/mod_python.so
>
>
> I have left my DocumentRoot Directory as follows:
>
>
>
>
> DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
>
>
>
> <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
>
>     AddHandler python-program .py
>
>     SetHandler mod_python

You shouldn't be specifying AddHandler and SetHandler at the same
time. So you can still serve static files, just define the AddHandler
directive.

>     PythonHandler hello
>
>     Options FollowSymLinks
>
>     AllowOverride None
>
>     Order deny,allow
>
>     Deny from all
>
> </Directory>
>
>
>
> I have moved my "hello.py" file into this directory.  The hello.py script
> looks like:
>
>
>
> from mod_python import apache
>
>
>
> def handler(req):
>
>      req.content_type = "text/plain"
>
>      req.send_http_header()
>
>      req.write("Hello, Welcome to my World!")
>
>      return apache.OK
>
>
>
>
>
> When I enter the request http://localhost/hello.py into my browser, I get
> the following error:
>
>
>
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was unable
> to complete your request.
>
> Please contact the server administrator, admin at localhost and inform them of
> the time the error occurred, and anything you might have done that may have
> caused the error.
>
> More information about this error may be available in the server error log.
>
>
>
> When I check the server error log, I receive the following:
>
>
>
> ImportError: No module named mod_python.apache
>
> [Mon Mar 17 13:48:11 2008] [error] make_obcallback: Python path being used
> "['C:\\\\Python24\\\\python24.zip', '.\\\\DLLs',
> '.\\\\lib', '.\\\\lib\\\\plat-win', '.\\\\lib\\\\lib-tk', 'C:\\\\Program
> Files\\\\Apache Software Foundation\\\\Apache2.2\\\\bin']".
>
> [Mon Mar 17 13:48:11 2008] [error] get_interpreter: no interpreter callback
> found.
>
> [Mon Mar 17 13:48:11 2008] [error] [client 127.0.0.1] python_handler: Can't
> get/create interpreter.
>
> [Mon Mar 17 13:50:55 2008] [notice] Parent: Received restart signal --
> Restarting the server.
>
> [Mon Mar 17 13:50:55 2008] [notice] Child 3324: Exit event signaled. Child
> process is ending.
>
> [Mon Mar 17 13:50:55 2008] [notice] Apache/2.2.8 (Win32) configured --
> resuming normal operations
>
> [Mon Mar 17 13:50:55 2008] [notice] Server built: Jan 18 2008 00:37:19
>
> [Mon Mar 17 13:50:55 2008] [notice] Parent: Created child process 3936
>
> [Mon Mar 17 13:50:55 2008] [notice] mod_python: Creating 8 session mutexes
> based on 0 max processes and 64 max threads.
>
> [Mon Mar 17 13:50:55 2008] [notice] Child 3936: Child process is running
>
> [Mon Mar 17 13:50:56 2008] [notice] Child 3324: Released the start mutex
>
> [Mon Mar 17 13:50:56 2008] [notice] Child 3936: Acquired the start mutex.
>
> [Mon Mar 17 13:50:56 2008] [notice] Child 3936: Starting 64 worker threads.
>
> [Mon Mar 17 13:50:57 2008] [notice] Child 3324: All worker threads have
> exited.
>
> [Mon Mar 17 13:50:57 2008] [notice] Child 3324: Child process is exiting
>
> [Mon Mar 17 13:50:57 2008] [notice] Child 3936: Starting thread to listen on
> port 80.
>
> [Mon Mar 17 13:51:15 2008] [error] make_obcallback: could not import
> mod_python.apache.\n
>
> 'import site' failed; use -v for traceback
>
> 'import site' failed; use -v for traceback
>
> ImportError: No module named mod_python.apache
>
> [Mon Mar 17 13:51:15 2008] [error] make_obcallback: Python path being used
> "['C:\\\\Python24\\\\python24.zip', '.\\\\DLLs',
> '.\\\\lib', '.\\\\lib\\\\plat-win', '.\\\\lib\\\\lib-tk', 'C:\\\\Program
> Files\\\\Apache Software Foundation\\\\Apache2.2\\\\bin']".
>
> [Mon Mar 17 13:51:15 2008] [error] get_interpreter: no interpreter callback
> found.
>
> [Mon Mar 17 13:51:15 2008] [error] [client 127.0.0.1] python_handler: Can't
> get/create interpreter.
>
>
>
> Can anyone shed any light on what the problem might be????

This is typically because Apache and Python were not installed as an
Administrator, or the Python installation or Apache installation, or
the mod_python installed parts are not accessible/readable by the user
that Apache runs as. There can also be a problem if you have multiple
versions of Python installed and Apache is finding the wrong version
for which mod_python was installed.

Often this problem is resolved by uninstalling Apache and Python and
reinstalling both as an Administrator.

Graham


More information about the Mod_python mailing list