Learning Python and ran into an issue trying to get my first script to run. When I ran the script by calling it from an HTML file, I would get a 500 Server Error. In the logs I saw this:
[Mon Oct 10 22:48:24.670771 2016] [cgi:error] [pid 312899:tid 140374432446208] [client 220.127.116.11:32291] AH01215: suexec policy violation: see suexec log for more details:
So I SSH’d into the box to try running the script manually, and got this:
-bash: ./test.py: /usr/bin/python^M: bad interpreter: No such file or directory
As it turns out, I was editing in JetBrains Webstorm on Windows, and uploading to a Linux server. Windows enters in new line returns as CRLF, where as Unix operating systems will only work if they see LF.
In WebStorm, you can change this setting by going to File, Line Separators and changing it. This is on a per file basis, and only needed for scripts being run through an interpreter. Running the script directly (python test.py) worked fine.