[mod_python] Error

Graham Dumpleton graham.dumpleton at gmail.com
Tue May 29 18:54:35 EDT 2007


So, after all that it is now working after all. I'm confused.

Graham

On 30/05/07, Idoia Villacián Zárate <fidita48 at hotmail.com> wrote:
>
>
>
> Hello,
>
>
>
> When I acces from my URL,that is
> http://localhost/mywebdir/mptest.py, where mptest.py is the
> following program:
>
>
>
> from mod_python import apache
>
>
>
> def handler(req):
>
>     req.content_type = 'text/plain'
>
>     req.write("Hello World!")
>
>     return apache.OK
>
>
>
> The localhost is DocumentRoot "C:/Archivos de programa/Apache Software
> Foundation/Apache2.2/htdocs", mywebdir is the folder where the file mptest
> is, and I get the message Hello world! And in the error log I get :
>
>
>
> [Tue May 29 17:06:49 2007] [notice] mod_python (pid=3844,
> interpreter='127.0.0.1'): Importing module 'C:\\Archivos de
> programa\\Apache Software
> Foundation\\Apache2.2\\htdocs\\mywebdir\\mptest.py'
>
>
>
> If I change the code for the one you give me:
> print "Content-type: text/html\n\n"
> print "Hello, World."
>
>  When I access to the URL y get a message MOD_PYTHON ERROR, and I don't get
> the Hello world, and in the apache's error lof I get the following:
>
>
>
>
> [Tue May 29 21:16:56 2007] [error] [client 127.0.0.1] mod_python (pid=2236,
> interpreter='127.0.0.1', phase='PythonHandler', handler='mptest'):
> Application error
> [Tue May 29 21:16:56 2007] [error] [client 127.0.0.1] ServerName:
> '127.0.0.1'
> [Tue May 29 21:16:56 2007] [error] [client 127.0.0.1] DocumentRoot:
> 'C:/Archivos de programa/Apache Software Foundation/Apache2.2/htdocs'
> [Tue May 29 21:16:56 2007] [error] [client 127.0.0.1] URI:
> '/mywebdir/mptest.py'
> [Tue May 29 21:16:56 2007] [error] [client 127.0.0.1] Location: None
> [Tue May 29 21:16:56 2007] [error] [client 127.0.0.1] Directory:
> 'C:/Archivos de programa/Apache Software
> Foundation/Apache2.2/htdocs/mywebdir/'
> [Tue May 29 21:16:56 2007] [error] [client 127.0.0.1] Filename: 'C:/Archivos
> de programa/Apache Software
> Foundation/Apache2.2/htdocs/mywebdir/mptest.py'
> [Tue May 29 21:16:56 2007] [error] [client 127.0.0.1] PathInfo: ''
> [Tue May 29 21:16:57 2007] [error] [client 127.0.0.1] Traceback (most recent
> call last):
> [Tue May 29 21:16:57 2007] [error] [client 127.0.0.1]   File
> "C:\\Python24\\Lib\\site-packages\\mod_python\\importer.py",
> line 1537, in HandlerDispatch\n
> default=default_handler, arg=req, silent=hlist.silent)
> [Tue May 29 21:16:57 2007] [error] [client 127.0.0.1]   File
> "C:\\Python24\\Lib\\site-packages\\mod_python\\importer.py",
> line 1206, in _process_target\n    object = apache.resolve_object(module,
> object_str, arg, silent=silent)
> [Tue May 29 21:16:57 2007] [error] [client 127.0.0.1]   File
> "C:\\Python24\\Lib\\site-packages\\mod_python\\apache.py",
> line 696, in resolve_object\n    raise AttributeError, s
> [Tue May 29 21:16:57 2007] [error] [client 127.0.0.1] AttributeError: module
> 'C:\\Archivos de programa\\Apache Software
> Foundation\\Apache2.2\\htdocs\\mywebdir\\mptest.py'
> contains no 'handler'
>
>
>
>
>  Thanks
>
>
>  ________________________________
>
> From:  "Graham Dumpleton" <graham.dumpleton at gmail.com>
> To:  "Idoia Villacián Zárate" <fidita48 at hotmail.com>
> CC:  mod_python at modpython.org
> Subject:  Re: [mod_python] Error
> Date:  Tue, 29 May 2007 08:20:23 +1000
> >Hmmm, no mention of CGI in those bits that may be relevant.
> >
> >Lets try this a different way. Replace your existing code file with
> >another with the same name but containing:
> >
> >  print "Content-type: text/html\n\n"
> >  print "Hello, World."
> >
> >When you access the URL you have been using, what is displayed in
> >your
> >browser and the error logs then?
> >
> >If this works okay, then it confirms your Apache must be configured
> >for CGI somehow and it is overriding mod_python.
> >
> >BTW, what URL are you actually using in your browser again. I don't
> >recollect seeing you post what you were using.
> >
> >You also may want to confirm whether you are indeed setting up
> >everything correctly by following alternate instructions in:
> >
> >
> >http://www.dscpl.com.au/wiki/ModPython/Articles/GettingModPythonWorking
> >
> >You will have to get htaccess files working for your Windows box
> >though.
> >
> >Graham
> >
> >On 29/05/07, Idoia Villacián Zárate <fidita48 at hotmail.com> wrote:
> >>
> >>
> >>
> >>Hello,
> >>
> >>
> >>
> >>What I have in apache's configuration is the following
> >>
> >>
> >>
> >><Directory "C:/Archivos de programa/Apache Software
> >>Foundation/Apache2.2/htdocs">
> >>
> >>     #
> >>
> >>     # Possible values for the Options directive are "None", "All",
> >>
> >>     # or any combination of:
> >>
> >>     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch
> >>ExecCGI
> >>MultiViews
> >>
> >>     #
> >>
> >>     # Note that "MultiViews" must be named *explicitly* ---
> >>"Options All"
> >>
> >>     # doesn't give it to you.
> >>
> >>     #
> >>
> >>     # The Options directive is both complicated and important.
> >>Please see
> >>
> >>     #
> >>http://httpd.apache.org/docs/2.2/mod/core.html#options
> >>
> >>     # for more information.
> >>
> >>     #
> >>
> >>     Options Indexes FollowSymLinks
> >>
> >>
> >>
> >>     #
> >>
> >>     # AllowOverride controls what directives may be placed in
> >>.htaccess
> >>files.
> >>
> >>     # It can be "All", "None", or any combination of the keywords:
> >>
> >>     #   Options FileInfo AuthConfig Limit
> >>
> >>     #
> >>
> >>     AllowOverride None
> >>
> >>
> >>
> >>     #
> >>
> >>     # Controls who can get stuff from this server.
> >>
> >>     #
> >>
> >>     Order allow,deny
> >>
> >>     Allow from all
> >>
> >>
> >>
> >></Directory>
> >>
> >>
> >>
> >>And finally:
> >>
> >>
> >>
> >>#AddHandler cgi-script .cgi
> >>
> >>
> >>
> >>Thanks
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>  ________________________________
> >>
> >>From:  "Graham Dumpleton" <graham.dumpleton at gmail.com>
> >>To:  "Idoia Villaci�n Z�rate" <fidita48 at hotmail.com>
>
> >>CC:  mod_python at modpython.org
> >>Subject:  Re: [mod_python] Error
> >>Date:  Sat, 26 May 2007 21:36:53 +1000
> >>
> >> >I was hoping for the region of the log file which also showed
> >>your
> >> >error:
> >> >
> >> >Traceback (most recent call last):
> >> >
> >> >  File "C:\Archivos de programa\Apache Software
> >> >Foundation\Apache2.2\htdocs\mptest.py", line 1, in ?
> >> >
> >> >    from mod_python import apache
> >> >
> >> >  File
> >>"C:\Python24\Lib\site-packages\mod_python\apache.py",
> line
> >> >30, in ?
> >> >
> >> >    import _apache
> >> >ImportError: No module named _apache
> >> >
> >> >embedded within the middle of it.
> >> >
> >> >Ie., something like:
> >> >
> >> >[Mon Apr 09 13:30:15 2007] [error] [client 127.0.0.1] mod_python
> >> >(pid=7293, interpreter='grumpy.local', phase='PythonHandler',
> >> >handler='paste.modpython'): Application error
> >> >[Mon Apr 09 13:30:15 2007] [error] [client 127.0.0.1] ServerName:
> >> >'grumpy.local'[Mon Apr 09 13:30:15 2007] [error] [client
> >>127.0.0.1]
> >> >DocumentRoot: '/usr/local/apache-2.2/htdocs'
> >> >[Mon Apr 09 13:30:15 2007] [error] [client 127.0.0.1] URI:
> >> >'/mod_python/hello'[Mon Apr 09 13:30:15 2007] [error] [client
> >> >127.0.0.1] Location: '/mod_python/hello'[Mon Apr 09 13:30:15
> >>2007]
> >> >[error] [client 127.0.0.1] Directory: None
> >> >[Mon Apr 09 13:30:15 2007] [error] [client 127.0.0.1] Filename:
> >> >'/usr/local/apache-2.2/htdocs/mod_python'
> >> >[Mon Apr 09 13:30:15 2007] [error] [client 127.0.0.1] PathInfo:
> >> >'/hello'
> >> >[Mon Apr 09 13:30:15 2007] [error] [client 127.0.0.1] Traceback
> >> >(most
> >> >recent call last):
> >> >[Mon Apr 09 13:30:15 2007] [error] [client 127.0.0.1]   File
> >>
> >"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/mod_python/importer.py",
> >> >line 1537, in HandlerDispatch\n
> >>default=default_handler, arg=req,
> >> >silent=hlist.silent)[Mon Apr 09 13:30:15 2007] [error] [client
> >> >127.0.0.1]   File
> >>
> >"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/mod_python/importer.py",
> >> >line 1229, in _process_target\n    result =
> >>_execute_target(config,
> >> >req, object, arg)[Mon Apr 09 13:30:15 2007] [error] [client
> >> >127.0.0.1]
> >> >  File
> >>
> >"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/mod_python/importer.py",
> >> >line 1128, in _execute_target\n    result = object(arg)[Mon Apr
> >>09
> >> >13:30:15 2007] [error] [client 127.0.0.1]   File
> >>
> >"/Library/Python/2.3/site-packages/Paste-1.2.1-py2.3.egg/paste/modpython.py",
> >> >line 246, in handler\n    module = __import__(modname, globals(),
> >> >locals(), [''])[Mon Apr 09 13:30:15 2007] [error] [client
> >>127.0.0.1]
> >> >File "/usr/local/wsgi/scripts/hello.py", line 3, in ?\n
> >>import
> >> >mod_wsgi[Mon Apr 09 13:30:15 2007] [error] [client 127.0.0.1]
> >> >ImportError: No module named mod_wsgi
> >> >
> >> >The thing I just realised though is that your error message can't
> >>be
> >> >a
> >> >result of a failure of mod_python as the way mod_python logs
> >> >tracebacks means that the details would have the timestamp
> >> >information
> >> >prefixing each line like above. That they don't appear means your
> >> >script is probably most definitely being executed as a CGI script
> >> >and
> >> >not by mod_python.
> >> >
> >> >Thus I would suggest you have a configuration problem with HTTP.
> >> >Specifically, you have CGI scripts enabled for that directory, or
> >> >for
> >> >the .py extension.
> >> >
> >> >What do you have elsewhere in your Apache configuration relating
> >>to
> >> >CGI scripts. Do you have anything like:
> >> >
> >> >  AddHandler cgi-script .py
> >> >
> >> >or:
> >> >
> >> >  Options ExecCGI
> >> >
> >> >Find that section of your configuration and reply-all and quote
> >>it.
> >> >
> >> >Graham
> >> >
> >> >
> >> >
> >> >On 26/05/07, Idoia Villacián Zárate <fidita48 at hotmail.com>
>
> >>wrote:
> >> >>
> >> >>
> >> >>I'm sorry, I didn't know I have to send back the mails, I'll do
> >>it
> >> >>from now.
> >> >>
> >> >>
> >> >>
> >> >>here I send you the lines of apache's log error:
> >> >>
> >> >>[Sat May 26 12:42:26 2007] [notice] Apache/2.2.4 (Win32)
> >>configured
> >> >>--
> >> >>resuming normal operations
> >> >>
> >> >>[Sat May 26 12:42:26 2007] [notice] Server built: Jan  9 2007
> >> >>23:17:20
> >> >>
> >> >>[Sat May 26 12:42:26 2007] [notice] Parent: Created child
> >>process
> >> >>1604
> >> >>
> >> >>[Sat May 26 12:42:27 2007] [notice] Child 1604: Child process is
> >> >>running
> >> >>
> >> >>[Sat May 26 12:42:27 2007] [notice] Child 1604: Acquired the
> >>start
> >> >>mutex.
> >> >>
> >> >>[Sat May 26 12:42:27 2007] [notice] Child 1604: Starting 250
> >>worker
> >> >>threads.
> >> >>
> >> >>[Sat May 26 12:42:27 2007] [notice] Child 1604: Starting thread
> >>to
> >> >>listen on
> >> >>port 80.
> >> >>
> >> >>[Sat May 26 12:59:04 2007] [notice] Parent: Received restart
> >>signal
> >> >>--
> >> >>Restarting the server.
> >> >>
> >> >>[Sat May 26 12:59:04 2007] [notice] Child 1604: Exit event
> >> >>signaled. Child
> >> >>process is ending.
> >> >>
> >> >>[Sat May 26 12:59:04 2007] [notice] Apache/2.2.4 (Win32)
> >>configured
> >> >>--
> >> >>resuming normal operations
> >> >>
> >> >>[Sat May 26 12:59:04 2007] [notice] Server built: Jan  9 2007
> >> >>23:17:20
> >> >>
> >> >>[Sat May 26 12:59:04 2007] [notice] Parent: Created child
> >>process
> >> >>5332
> >> >>
> >> >>[Sat May 26 12:59:05 2007] [error] python_init: Python version
> >> >>mismatch,
> >> >>expected '2.4.3', found '2.4.4'.
> >> >>
> >> >>[Sat May 26 12:59:05 2007] [error] python_init: Python
> >>executable
> >> >>found
> >> >>'C:\\Archivos de programa\\Apache Software
> >> >>Foundation\\Apache2.2\\bin\\httpd.exe'.
> >> >>
> >> >>[Sat May 26 12:59:05 2007] [error] python_init: Python path
> >>being
> >> >>used
> >>
> >>'C:\\WINDOWS\\system32\\python24.zip;C:\\Python24\\Lib;C:\\Python24\\DLLs;C:\\Python24\\Lib\\lib-tk;;C:\\Archivos
> >> >>de programa\\Apache Software Foundation\\Apache2.2\\bin'.
> >> >>
> >> >>[Sat May 26 12:59:05 2007] [notice] mod_python: Creating 8
> >>session
> >> >>mutexes
> >> >>based on 0 max processes and 250 max threads.
> >> >>
> >> >>[Sat May 26 12:59:05 2007] [notice] Child 5332: Child process is
> >> >>running
> >> >>
> >> >>[Sat May 26 12:59:05 2007] [notice] Child 1604: Released the
> >>start
> >> >>mutex
> >> >>
> >> >>[Sat May 26 12:59:05 2007] [notice] Child 5332: Acquired the
> >>start
> >> >>mutex.
> >> >>
> >> >>[Sat May 26 12:59:05 2007] [notice] Child 5332: Starting 250
> >>worker
> >> >>threads.
> >> >>
> >> >>[Sat May 26 12:59:06 2007] [notice] Child 1604: Waiting for 250
> >> >>worker
> >> >>threads to exit.
> >> >>
> >> >>[Sat May 26 12:59:06 2007] [notice] Child 1604: All worker
> >>threads
> >> >>have
> >> >>exited.
> >> >>
> >> >>[Sat May 26 12:59:06 2007] [notice] Child 1604: Child process is
> >> >>exiting
> >> >>
> >> >>[Sat May 26 12:59:06 2007] [notice] Child 5332: Starting thread
> >>to
> >> >>listen on
> >> >>port 80.
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [notice] Parent: Received restart
> >>signal
> >> >>--
> >> >>Restarting the server.
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [notice] Child 5332: Exit event
> >> >>signaled. Child
> >> >>process is ending.
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [notice] Apache/2.2.4 (Win32)
> >>configured
> >> >>--
> >> >>resuming normal operations
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [notice] Server built: Jan  9 2007
> >> >>23:17:20
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [notice] Parent: Created child
> >>process
> >> >>3408
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [error] python_init: Python version
> >> >>mismatch,
> >> >>expected '2.4.3', found '2.4.4'.
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [error] python_init: Python
> >>executable
> >> >>found
> >> >>'C:\\Archivos de programa\\Apache Software
> >> >>Foundation\\Apache2.2\\bin\\httpd.exe'.
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [error] python_init: Python path
> >>being
> >> >>used
> >>
> >>'C:\\WINDOWS\\system32\\python24.zip;C:\\Python24\\Lib;C:\\Python24\\DLLs;C:\\Python24\\Lib\\lib-tk;;C:\\Archivos
> >> >>de programa\\Apache Software Foundation\\Apache2.2\\bin'.
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [notice] mod_python: Creating 8
> >>session
> >> >>mutexes
> >> >>based on 0 max processes and 250 max threads.
> >> >>
> >> >>[Sat May 26 13:00:22 2007] [notice] Child 3408: Child process is
> >> >>running
> >> >>
> >> >>[Sat May 26 13:00:23 2007] [notice] Child 5332: Released the
> >>start
> >> >>mutex
> >> >>
> >> >>[Sat May 26 13:00:23 2007] [notice] Child 3408: Acquired the
> >>start
> >> >>mutex.
> >> >>
> >> >>[Sat May 26 13:00:23 2007] [notice] Child 3408: Starting 250
> >>worker
> >> >>threads.
> >> >>
> >> >>[Sat May 26 13:00:23 2007] [notice] Child 3408: Starting thread
> >>to
> >> >>listen on
> >> >>port 80.
> >> >>
> >> >>[Sat May 26 13:00:24 2007] [notice] Child 5332: Waiting for 250
> >> >>worker
> >> >>threads to exit.
> >> >>
> >> >>[Sat May 26 13:00:24 2007] [notice] Child 5332: All worker
> >>threads
> >> >>have
> >> >>exited.
> >> >>
> >> >>[Sat May 26 13:00:24 2007] [notice] Child 5332: Child process is
> >> >>exiting
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [notice] Parent: Received restart
> >>signal
> >> >>--
> >> >>Restarting the server.
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [notice] Child 3408: Exit event
> >> >>signaled. Child
> >> >>process is ending.
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [notice] Apache/2.2.4 (Win32)
> >>configured
> >> >>--
> >> >>resuming normal operations
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [notice] Server built: Jan  9 2007
> >> >>23:17:20
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [notice] Parent: Created child
> >>process
> >> >>6388
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [error] python_init: Python version
> >> >>mismatch,
> >> >>expected '2.4.3', found '2.4.4'.
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [error] python_init: Python
> >>executable
> >> >>found
> >> >>'C:\\Archivos de programa\\Apache Software
> >> >>Foundation\\Apache2.2\\bin\\httpd.exe'.
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [error] python_init: Python path
> >>being
> >> >>used
> >>
> >>'C:\\WINDOWS\\system32\\python24.zip;C:\\Python24\\Lib;C:\\Python24\\DLLs;C:\\Python24\\Lib\\lib-tk;;C:\\Archivos
> >> >>de programa\\Apache Software Foundation\\Apache2.2\\bin'.
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [notice] mod_python: Creating 8
> >>session
> >> >>mutexes
> >> >>based on 0 max processes and 250 max threads.
> >> >>
> >> >>[Sat May 26 13:06:54 2007] [notice] Child 6388: Child process is
> >> >>running
> >> >>
> >> >>[Sat May 26 13:06:55 2007] [notice] Child 3408: Released the
> >>start
> >> >>mutex
> >> >>
> >> >>[Sat May 26 13:06:55 2007] [notice] Child 6388: Acquired the
> >>start
> >> >>mutex.
> >> >>
> >> >>[Sat May 26 13:06:55 2007] [notice] Child 6388: Starting 250
> >>worker
> >> >>threads.
> >> >>
> >> >>[Sat May 26 13:06:55 2007] [notice] Child 6388: Starting thread
> >>to
> >> >>listen on
> >> >>port 80.
> >> >>
> >> >>[Sat May 26 13:06:56 2007] [notice] Child 3408: Waiting for 250
> >> >>worker
> >> >>threads to exit.
> >> >>
> >> >>[Sat May 26 13:06:56 2007] [notice] Child 3408: All worker
> >>threads
> >> >>have
> >> >>exited.
> >> >>
> >> >>[Sat May 26 13:06:56 2007] [notice] Child 3408: Child process is
> >> >>exiting
> >> >>
> >> >>
> >> >>
> >> >>Thanks
> >> >>
> >> >>
> >> >>________________________________
> >> >>Acepta el reto MSN Premium: Env�a hasta 500 megas diarios de
> >> >>fotos desde
> >> >>Hotmail. Desc�rgalo y pru�balo 2 meses gratis.
> >>
> >>________________________________
> >>Acepta el reto MSN Premium: Env�a hasta 500 megas diarios de
> >>fotos desde
> >>Hotmail. Desc�rgalo y pru�balo 2 meses gratis.
>
> ________________________________
> Encuentra una aventura, un romance o al amor de tu vida. Date de alta
> gratis.



More information about the Mod_python mailing list