Configuring mod_python

I can’t get apache to publish my .py files (except as text). mod_python is installed and is apparently loaded into apache Ok.

Going on what I’ve googled In one of my virtual host files I’ve got …

<snip>
<Directory “/path/to/my/document/root”>
AddHandler mod_python .py
PythonPath “’/usr/bin/python2.5’, ‘/usr/bin/python’]”
PythonHandler mod_python.publisher
PythonDebug On
</Directory>
</snip>

If I try to access a simple python script (test.py) which simply holds a print <some html> statement my browser comes up with

<snip>
Mod_python error: “PythonHandler mod_python.publisher”
Traceback (most recent call last):
File “/usr/lib/python2.5/site-packages/mod_python/apache.py”, line 287, in HandlerDispatch
log=debug)
File “/usr/lib/python2.5/site-packages/mod_python/apache.py”, line 461, in import_module
f, p, d = imp.find_module(parts*, path)
ImportError: No module named mod_python
</snip>

Where am I going wrong?*

Hmm, maybe this link might help:

ModPython/Articles/GettingModPythonWorking - Graham’s Project Wiki

especially the bits about testing with the CLI python first.

ken yap wrote:

>
> Hmm, maybe this link might help:
>
> ‘ModPython/Articles/GettingModPythonWorking - Graham’s Project Wiki’
> (http://tinyurl.com/2pwc5e)
>
> especially the bits about testing with the CLI python first.
>
>

I get as far as the bit that displays “mptest.py” on the browser but I can’t
get any further.

Presumably this means that mod_python is there and running is just some
configuration in httpd.conf that needs setting - I’ll keep digging but the
apache configuration is a confusing minefield.

Alan


email =~ s/nospam/fudokai/

ajp wrote:

> ken yap wrote:
>
>>
>> Hmm, maybe this link might help:
>>
>> ‘ModPython/Articles/GettingModPythonWorking - Graham’s Project Wiki’
>> (http://tinyurl.com/2pwc5e)
>>
>> especially the bits about testing with the CLI python first.
>>
>>
>
> I get as far as the bit that displays “mptest.py” on the browser but I
> can’t get any further.
>
> Presumably this means that mod_python is there and running is just some
> configuration in httpd.conf that needs setting - I’ll keep digging but the
> apache configuration is a confusing minefield.
>
> Alan
>

Ok - I’ve got it working as I wanted - running .py as CGI so that it matches
how things work on my hosted site. Now I can test things locally before
uploading to the live site.

FYI - the apache config ended up as
<snip>
AddHandler mod_python .py
PythonHandler mod_python.cgihandler
PythonDebug On
</snip>

I realise that publisher is the recommended, thread-safe option but I needed
to match the setup at my hosting company.

Alan


email =~ s/nospam/fudokai/