[mod_python] Installation problems with mod_python

Graham Dumpleton graham.dumpleton at gmail.com
Thu May 10 02:27:11 EDT 2007


On 09/05/07, Ben Thompson <ben at kilgore.demon.co.uk> wrote:
>
>
> 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>

What is your 'DocumentRoot' directive set to which indicates where
your Apache document root directory is? If for some reason it doesn't
match as a prefix to the above locations it may not work as a result.

Unless  I am missing the obvious, the configuration otherwise looks okay.

BTW, what is the actual URL you are using to access the page?

> 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.

That appears to be because a change suggested by someone:

  http://issues.apache.org/jira/browse/MODPYTHON-195

was actually not completely correct.

It causes no harm in the scheme of things but means the initialisation
message for mod_python/Python isn't shown in the error logs. I have
reopened that issue so it can be fixed in a future version.

> [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'.

This shouldn't cause an issue, but your mod_python was compiled
against a different version of Python than you are using.

> 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.

In your Apache configuration files, what is the directive
'AccessFileName' set to. This is what dictates what the htaccess file
will be named. As far as I know you can still call files .htaccess on
Windows, but often more convenient to call it something else. If you
are changing it, you may also have to change:

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>

to something more appropriate so the files aren't accessible.

> E:/Projects/Web/Home/htdocs/test/htaccess contains:
>
>
> AddHandler mod_python .py
>
> PythonHandler mptest
>
> PythonDebug On

The best way of determing if a htaccess file is being read is to put a
syntax error in it. That way it should yield a 500 error. Ie., put a
line in it containing:

  XXXERROR

Graham


More information about the Mod_python mailing list