[mod_python] Testing Mod_python

Graham Dumpleton graham.dumpleton at gmail.com
Fri Aug 31 18:34:10 EDT 2007


On 01/09/2007, Chris Howell <chowell at pyxisinnovation.com> wrote:
>
>  Hi All.
>
>  So I got  mod_python installed, with apache on my windows box running WinXP
> SP2. When I went to test the mod_install following the directions on this
> site.
>
> http://www.modpython.org/live/current/doc-html/inst-testing.html
>
>  I put the directory in this my httpd.conf file, and it looks like this.
>
>  <Directory "C:/Program Files/Apache Software
> Foundation/Apache2.2/htdocs/test">
>    Options FollowSymLinks
>    AllowOverride All
>    Order deny,allow
>    Satisfy all
>    AddHandler mod_python .py
>    PythonHandler mptest
>    PythonDebug On
>  </Directory>
>
>  I restarted the Apache server no problem.
>
>  My python test file looks like.
>
>  from mod_python import apache
>
>  def handler(req):
>      req.content_type = 'text/plain'
>      req.write("Hello World")
>      return apache.OK
>  File name: mptest.py and it's in the appropriate directory and everything.
>
>  When I try to point by browser URL at the python file with this.
>
>  http://euclid:9000/Test/mptest.py
>
>  I get this error message.
>
>  MOD_PYTHON ERROR
>
> ProcessId: 1652
> Interpreter: 'euclid.PyxisInnovation.local'
>
> ServerName: 'euclid.PyxisInnovation.local'
> DocumentRoot: 'C:/Program Files/Apache Software Foundation/Apache2.2/htdocs'
>
> URI: '/Test/mptest.py'
> Location: None
> Directory: 'C:/Program Files/Apache Software
> Foundation/Apache2.2/htdocs/Test/'
> Filename: 'C:/Program Files/Apache Software
> Foundation/Apache2.2/htdocs/Test/mptest.py'
> PathInfo: ''
>
> Phase: 'PythonHandler'
> Handler: 'mptest'
>
> Traceback (most recent call last):
>
>  File
> "C:\Python25\Lib\site-packages\mod_python\importer.py",
> line 1537, in HandlerDispatch
>  default=default_handler, arg=req, silent=hlist.silent)
>
>  File
> "C:\Python25\Lib\site-packages\mod_python\importer.py",
> line 1202, in _process_target
>  module = import_module(module_name, path=path)
>
>  File
> "C:\Python25\Lib\site-packages\mod_python\importer.py",
> line 304, in import_module
>  return __import__(module_name, {}, {}, ['*'])
>
> ImportError: No module named mptest
>
>  Any help would be great.

If you put a plain text file 'hello.txt' in the 'test' subdirectory,
can you access it from browser as:

  /Test/hello.txt

If you can't, and you are running Apache as a service, then it means
Apache doesn't have appropriate permissions to read the contents of
that subdirectory.

BTW, keep trying to use this method, as most of the time Apache on
Win32 isn't set up quite correctly such that .htaccess works.

Graham


More information about the Mod_python mailing list