If you have this problem on *nix systems, these are the things to look for:
1 – Make sure your line breaks are \n not \r\n you can set this in almost all editors, you will have to either select *nix like line breaks or \n somewhere in your editor preferences.
2 – After the first step you will have to make sure that your FTP client uploads the files in ASCII format and this will insure that \n will stay \n.
3 – If it still doesn’t work, make sure your Python script’s permissions are 755. You can try:
chmod 755 your_python_script.py
Or use your FTP client to fix this. (Refer to it’s documentation but usually you can right click on the file, on your server and click properties)
4 – If you still have the problem, you will have to have the right shebang line in the beginning of your script, the most common one is:
#!/usr/bin/env python
If this doesn’t work try:
#!/usr/bin/python
Or:
#!/usr/local/bin/python
Note that, this must be the first line
5 – If none of these worked and you have root access to your server, try:
tail -f /usr/local/apache/logs/error_log (Note that, the path to Apache error log might be different on your server)
And look for the error message associated with your request.
6 – If you still can’t figure it out, write to your hosting company and ask them.
I hope this helps
Hamid Alipour is a partner in Codehead, LLP with his wife, Tess. Hamid speaks 12 markup and programming languages [Yes, 12: PHP, CSS, Ajax, JavaScript, HTML/XHTML, Java, Python, C/C++, ASP, Visual Basic, Scheme and Action Script]; has a penchant for solving the unsolvable; an affinity for clean, hand-written code and is a Zend Certified 
I found this useful and wrote up a small article on my site about my trial and error approach to resolving my error 500 nightmare! Thanks for the thoroughness!
Comment — December 5, 2009 @ 10:22 pm
thank you your information is helpfull
Comment — January 26, 2010 @ 7:05 am