[mod_python] Error

Jim Gallacher jpg at jgassociates.ca
Tue May 22 16:24:50 EDT 2007


Idoia Villacián Zárate wrote:
> I’m using mod_python 3.3.1  with apache 2.2.4 and python 2.4 in Windows XP
> 
> Everything intalls correctly, and when I install mod_phyton I add this line:
> 
> LoadModule python_module modules/mod_python.so
> 
> then in the conf of apache I add the following lines:
> 
> <Directory "C:\Archivos de programa\Apache Software Foundation\Apache2.2\htdocs">
> 
>         AddHandler mod_python .py
> 
>         PythonHandler mptest
> 
>         PythonDebug On
> 
>     </Directory>
> 
> And I write the following program which is called mptest:
> 
> from mod_python import apache
> 
> def handler(req):
>         req.content_type = 'text/plain'
>         req.write("Hello World!")
>         return apache.OK
> 
>  I compile the program and I get this error:
> 
> Traceback (most recent call last):
>   File "C:\Archivos de programa\Apache Software 
> Foundation\Apache2.2\htdocs\mptest.py", line 1, in -toplevel-
>     from mod_python import apache
>   File "C:\Python24\Lib\site-packages\mod_python\apache.py", line 30, in -toplevel-
>     import _apache
> ImportError: No module named _apache
> 
>  
> 
> If I go to apache, which is inside de folder of mod_python I see tha in its 
> comand’s line makes a call to _apache, which is not installed anywhere. That’s 
> why I get the error, how can I get that module?

You can't import _apache from a command line interpreter. It is a 
builtin module provided by mod_python.so and can only be accessed from 
within apache.

Jim


More information about the Mod_python mailing list