Today, I wrote a Python script on the computer, and then I wrote it with FTP, then executed the/var/www/cron.py, the result error,/bin/usr/python:bad interpreter:no such file or directory, Before the implementation of the python/var/www/cron.py is no problem ah, it seems that the code is not a problem.
Search on the Internet, a lot of people are reflected in the Python file is written in Windows due to the coding problem execution error (Windows line break is ' \ R '), and Linux is ' \ n '), so check the cron.py, with Vim open, and then use the command mode input " Set FF ", the result output" Filefomat=dos ", really is the problem here, then execute set Ff=unix, set to the Linux file encoding, Wq save, and then re-execute/var/www/cron.py,ok normal.
Sometimes it may not be the problem, it may be the path of the Python interpreter, this depends on the installation of Python when the/usr/bin/python link to the corresponding Python version, to the "/bin/usr/" path, "LS python "Well, no problem, but showing Python is just a symbolic link," ls-l python, "Output:
lrwxrwxrwx 1 root root 9 2010-07-08 12:35 python--python2.7
The workaround is to modify "#!/usr/bin/python" to "#!/usr/bin/python2.7" and then re-execute the Python script, which is generally possible, and it is recommended to write/usr/bin/env python. This will automatically find the path for the Python version.
Execute python "/bin/usr/python:bad interpreter:no such file or directory" error