Execute python "/bin/usr/python:bad interpreter:no such file or directory" error

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.