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

I'm a programmer at 
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
thank you your information is helpfull
Comment
thank you very much. you really save me!
Comment
Good post. Forgot to update my shebang with the right version of Python. Have a few installed
Comment
Thank you very much! I finally managed to run my python script after I give it the permission to run as excutable, followed your tip 4
Comment
I am using justhost, all these steps didn’t seem to help. I will contact the live chat.
Comment