Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38655 > unrolled thread
| Started by | Gilles <nospam@nospam.com> |
|---|---|
| First post | 2013-02-11 10:30 +0100 |
| Last post | 2013-02-11 13:04 +0100 |
| Articles | 8 — 2 participants |
Back to article view | Back to comp.lang.python
[2.4.3/Newbie] Web script doesn't run Gilles <nospam@nospam.com> - 2013-02-11 10:30 +0100
Re: [2.4.3/Newbie] Web script doesn't run Gilles <nospam@nospam.com> - 2013-02-11 10:39 +0100
Re: [2.4.3/Newbie] Web script doesn't run Chris Angelico <rosuav@gmail.com> - 2013-02-11 21:30 +1100
Re: [2.4.3/Newbie] Web script doesn't run Gilles <nospam@nospam.com> - 2013-02-11 12:22 +0100
Re: [2.4.3/Newbie] Web script doesn't run Chris Angelico <rosuav@gmail.com> - 2013-02-11 22:30 +1100
Re: [2.4.3/Newbie] Web script doesn't run Gilles <nospam@nospam.com> - 2013-02-11 12:36 +0100
Re: [2.4.3/Newbie] Web script doesn't run Chris Angelico <rosuav@gmail.com> - 2013-02-11 22:42 +1100
Re: [2.4.3/Newbie] Web script doesn't run Gilles <nospam@nospam.com> - 2013-02-11 13:04 +0100
| From | Gilles <nospam@nospam.com> |
|---|---|
| Date | 2013-02-11 10:30 +0100 |
| Subject | [2.4.3/Newbie] Web script doesn't run |
| Message-ID | <67ehh8t2nkf0eiqge34fnc0q6r31g648qo@4ax.com> |
Hello
I have a couple of newbie questions about using Python in a FastCGI
+ Flup context on a shared CentOS server:
1. The following script runs fine...
=========================
#!/usr/bin/env python2.6
def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Done!\n']
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp).run()
=========================
... while this triggers an error:
=========================
#!/usr/bin/env python2.6
# -*- coding: UTF-8 -*-
from cgi import escape
import sys, os
def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
yield '<h1>FastCGI Environment</h1>'
yield '<table>'
for k, v in sorted(environ.items()):
yield '<tr><th>%s</th><td>%s</td></tr>' % (escape(k),
escape(v))
yield '</table>'
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(app).run()
=========================
"Internal Server Error: The server encountered an internal error or
misconfiguration and was unable to complete your request. [...]
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request."
2. Generally speaking, what is the right way to investigate an error
in a Python web script? FWIW I have access to the shared server
through SSH.
Thank you.
[toc] | [next] | [standalone]
| From | Gilles <nospam@nospam.com> |
|---|---|
| Date | 2013-02-11 10:39 +0100 |
| Message-ID | <a0fhh89f0u2rj24jtauneeddh246dhu576@4ax.com> |
| In reply to | #38655 |
On Mon, 11 Feb 2013 10:30:01 +0100, Gilles <nospam@nospam.com> wrote: > I have a couple of newbie questions about using Python in a FastCGI >+ Flup context on a shared CentOS server: Please ignore the thread. I found the error, and a way to catch compile-time errors (log on through SSH, and run "python ./myscript.py").
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-02-11 21:30 +1100 |
| Message-ID | <mailman.1633.1360578621.2939.python-list@python.org> |
| In reply to | #38656 |
On Mon, Feb 11, 2013 at 8:39 PM, Gilles <nospam@nospam.com> wrote: > On Mon, 11 Feb 2013 10:30:01 +0100, Gilles <nospam@nospam.com> wrote: >> I have a couple of newbie questions about using Python in a FastCGI >>+ Flup context on a shared CentOS server: > > Please ignore the thread. I found the error, and a way to catch > compile-time errors (log on through SSH, and run "python > ./myscript.py"). That'll catch some forms of error, but not everything. You may also want to consider looking for your server's error log - that may be getting the actual traceback. I don't know what your server setup is, but there's likely to be one somewhere. A question though. You say "2.4.3" in your subject line, but your shebang says python2.6 - which version are you actually running? At very least, I'd recommend using python2.6 to run your script from the shell; if there's any incompatibility between the system Python (which quite plausibly would be the 2.4.3 you named) and the one your CGI script uses (named python2.6 and my guess would be that it's 2.6.6), you'll confuse yourself when you do your "shell test". ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Gilles <nospam@nospam.com> |
|---|---|
| Date | 2013-02-11 12:22 +0100 |
| Message-ID | <pmkhh8hva74m5h3571q2qk48p9eubh7v74@4ax.com> |
| In reply to | #38657 |
On Mon, 11 Feb 2013 21:30:12 +1100, Chris Angelico <rosuav@gmail.com> wrote: >That'll catch some forms of error, but not everything. You may also >want to consider looking for your server's error log - that may be >getting the actual traceback. I don't know what your server setup is, >but there's likely to be one somewhere. Good to know. >A question though. You say "2.4.3" in your subject line, but your >shebang says python2.6 - which version are you actually running? I didn't pay attention to this. Support says that I should use 2.6, but running "python -V" through SSH says 2.4.3. I'll ask support which to use. Thank you.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-02-11 22:30 +1100 |
| Message-ID | <mailman.1635.1360582248.2939.python-list@python.org> |
| In reply to | #38659 |
On Mon, Feb 11, 2013 at 10:22 PM, Gilles <nospam@nospam.com> wrote: > On Mon, 11 Feb 2013 21:30:12 +1100, Chris Angelico <rosuav@gmail.com> > wrote: >>That'll catch some forms of error, but not everything. You may also >>want to consider looking for your server's error log - that may be >>getting the actual traceback. I don't know what your server setup is, >>but there's likely to be one somewhere. > > Good to know. > >>A question though. You say "2.4.3" in your subject line, but your >>shebang says python2.6 - which version are you actually running? > > I didn't pay attention to this. Support says that I should use 2.6, > but running "python -V" through SSH says 2.4.3. I'll ask support which > to use. Try running python2.6 -V Your shebang line says that it's looking for a program named "python2.6", which is quite probably not the same as the one named just "python". ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Gilles <nospam@nospam.com> |
|---|---|
| Date | 2013-02-11 12:36 +0100 |
| Message-ID | <bslhh8lgi6bjdp9cddkjiu1fvqf65pecef@4ax.com> |
| In reply to | #38660 |
On Mon, 11 Feb 2013 22:30:45 +1100, Chris Angelico <rosuav@gmail.com> wrote: >Try running python2.6 -V > >Your shebang line says that it's looking for a program named >"python2.6", which is quite probably not the same as the one named >just "python". Indeed, they have two versions of Python installed: # python2.6 -V Python 2.6.4 # python -V Python 2.4.3 I'll make sure to use 2.6. Thank you.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-02-11 22:42 +1100 |
| Message-ID | <mailman.1636.1360582978.2939.python-list@python.org> |
| In reply to | #38661 |
On Mon, Feb 11, 2013 at 10:36 PM, Gilles <nospam@nospam.com> wrote: > On Mon, 11 Feb 2013 22:30:45 +1100, Chris Angelico <rosuav@gmail.com> > wrote: >>Try running python2.6 -V >> >>Your shebang line says that it's looking for a program named >>"python2.6", which is quite probably not the same as the one named >>just "python". > > Indeed, they have two versions of Python installed: > > # python2.6 -V > Python 2.6.4 > > # python -V > Python 2.4.3 > > I'll make sure to use 2.6. It's entirely possible you have a third Python, a 3.x, as well. Different Pythons coexist quite happily on a system. Anyway, seems your issue's sorted out. Yay! ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Gilles <nospam@nospam.com> |
|---|---|
| Date | 2013-02-11 13:04 +0100 |
| Message-ID | <9hnhh8hnubsh9udt89i25umd8loprlf336@4ax.com> |
| In reply to | #38662 |
On Mon, 11 Feb 2013 22:42:50 +1100, Chris Angelico <rosuav@gmail.com> wrote: >It's entirely possible you have a third Python, a 3.x, as well. >Different Pythons coexist quite happily on a system. Thank for the help. I'm on my way to figure out how mod_fcgid, Flup, and Python scripts work together.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web