[mod_python] [SPAM] Re: mod_python installation failure on apache

Martin (gzlist) gzlist at googlemail.com
Fri May 9 15:41:33 EDT 2008

> On Fri, May 9, 2008 at 2:27 PM, David Jackson <davidj411 at gmail.com> wrote:
> > I followed the directions at
> http://www.modpython.org/live/current/doc-html/inst-testing.html
> > and get contents of the script mptest.py , not the results as if it had
> run.

I think people often have this problem, for one reason or another.
Have you searched the mailing list archives?

An even simpler test to see if you've got the basic installation right
is to add to your httpd.conf file:

# with the module imported further up:
#LoadModule python_module modules/mod_python.so
<Location /mpinfo>
	SetHandler mod_python
	PythonHandler mod_python.testhandler
	Order deny,allow
	Deny from all
	Allow from 127.0

Restart, then visit http://localhost/mpinfo as see if you get the page.

> > if i run the mptest.py script from the command line, i get this import
> error.
> >
> > C:\apache\htdocs\py>mptest.py
> > Traceback (most recent call last):
> >   File "C:\apache\htdocs\py\mptest.py", line 1, in
> <module>
> >     from mod_python import apache
> >   File
> "C:\Python25\lib\site-packages\mod_python\apache.py", line
> 30, in <module>
> >     import _apache
> > ImportError: No module named _apache
> >
> > I have rebooted and restarted apache. It looks like the script apache.py
> mis-typed "apache" as "_apache" ?

No, _apache is the C module mod_python needs to interface with the
http server. It only exists when running from within the httpd, you
can't run scripts independently from the command line.

On 09/05/2008, David Jackson <davidj411 at gmail.com> wrote:
> more info, the apache module does not seem to exist in mod_python.
> is that what this means?
> import mod_python
> >>> dir (mod_python)
> ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__path__',
> 'version']

This is normal, modules need not import their sub-modules by default:

>>> import xml
>>> "dom" in dir(xml)
>>> import xml.dom
>>> "dom" in dir(xml)


More information about the Mod_python mailing list