[mod_python] ImportError: No module named mptest

Thomas Ryan thomas.ryan at earthlink.net
Tue Oct 5 16:33:45 EDT 2004


I had the same configuration Apache <-> mod_python problem as a number of
folks out here.
I had to dig longer than was reasonable to deduce the simple answer. Maybe I
didn't look in the right places.

So, with respect to some earlier posts, yes, Patrick the manual is helpful -
I'll try to be more helpful -
>
> Patrick Percot ppercot at free.fr
> Fri Jun 25 18:45:48 EDT 2004
>   I will answer all your questions by the famous RTFM :)
>
>   And the f... manual is here :
>
>         http://modpython.org/live/current/doc-html/tut-what-it-do.html
>
>
> [....deleted..]
> Mod_python error: "PythonHandler mptest"
>
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 181,
in Dispatch
>     module = import_module(module_name, _req)
>
>   File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 332,
in import_module
>     f, p, d = imp.find_module(parts[i], path)
>
>
> ImportError: No module named mptest
>

Unfortunately, the mod_python manual doesn't bother to mention the need to
also extend PYTHONPATH.
This is probably obvious to Python experts.

For those of you who someday google this, and who have RTFM, but are still
stuck with the "mptest module not found" import errors, try adding something
like the  following to the <Directory> entry in your Apache config file:
<Directory>
   ....
    AddHandler mod_python .py
    PythonPath "['C:/Program Files/Apache Group/Apache2/htdocs']+sys.path"
    PythonHandler mptest
    PythonDebug ON
</Directory>

And stick the sample mptest.py in the htdocs directory referred to above.

FWIW This is a Windows 2000 installation - Apache 2.0.5, mod_python 3.1.3
For this configuration, Apache generated errors in the system event log
complaining about too many <Directory> entries.
The manual glossed over this little tidbit too, but there's a simple fix:
add the mod_python stuff after the first <Directory> tag; don't make new
ones.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://modpython.org/pipermail/mod_python/attachments/20041005/31ad1bb5/attachment.html


More information about the Mod_python mailing list