[BangPypers] Running my first python script using mod_python

Bharath Keshav bharath.keshav at gmail.com
Wed May 28 10:40:51 CEST 2008


Just delete the extra white space characters(if there is any) before def
handler(request) in test.py and see. It is very much required to be careful
about indentation in python. Also, your handler is being shown as "test". In
apache htttpd.conf file try setting SetHandler  as python-program and then
set the python path as something like PYTHONPATH
"['C:\\\\Python25\\\\Lib\\\\site-packages\\\\django\\\\bin'] + sys.path".

Thanks and regards,
Bharath Keshav.

On Wed, May 28, 2008 at 1:16 PM, arindam majumdar <ari.majumdar84 at gmail.com>
wrote:

> Hi Guys,
> I am pretty new to python and was trying to execute my first python script
> which the same old hello world.
> I am running fedora core 8, apache 2.2.8 and python 3.1.
>
> MOD_PYTHON ERROR
>
> ProcessId:      9571
>
>
>
> Interpreter:    'localhost.localdomain'
>
> ServerName:     'localhost.localdomain'
> DocumentRoot:   '/var/www/html'
>
> URI:            '/mptest.py'
> Location:       None
>
> Directory:      '/var/www/html/'
>
>
> Filename:       '/var/www/html/mptest.py'
> PathInfo:       ''
>
> Phase:          'PythonHandler'
> Handler:        'test'
>
> Traceback (most recent call last):
>
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
>
>
>     default=default_handler, arg=req, silent=hlist.silent)
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1202, in _process_target
>
>     module = import_module(module_name, path=path)
>
>
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 296, in import_module
>     log, import_path)
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 680, in import_module
>
>
>
>     execfile(file, module.__dict__)
>
>   File "/var/www/html/test.py", line 3
>
>     def handler(req):
>
>    ^
>
> IndentationError: unexpected indent
>
>
> MODULE CACHE DETAILS
>
>
> Accessed:       Wed May 28 12:13:56 2008
>
>
> Generation:     0
>
> _mp_a0c997aa0dc877af47e755b6b2a27f16 {
>   FileName:     '/var/www/html/test.py'
>   Instance:     1 [IMPORT]
>   Generation:   0 [ERROR]
>
>   Modified:     Wed May 28 11:58:12 2008
>
>
> }
>
> Any help would be great.
>
> Cheers,
> Arindam MAjumdar
>
> --
> I would have changed myself, but God didn't release the source code.
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/bangpypers/attachments/20080528/6cf39f03/attachment-0001.htm>


More information about the BangPypers mailing list