: poor interpreter: no such file or directory in python

I was originally encoded in the python IDE on windows. Now that I have pasted my code into a file on a Linux server. Now when I run the script, it gives me this error:

bad interpreter: no such file or directory

Tell us how to solve this error.

+7
source share
2 answers

Perhaps you have \r\n line endings, where \r is the carriage return and \n is the newline character

This means that the first line could be like this:

 #!/usr/bin/env python\r\n 

or

 #!/usr/bin/python\r\n 

so the shell is trying to run the python\r command

+23
source

You are probably using the hashbang #!python convention, which is inexplicably popular among Windows users. Linux expects the full path. Use #!/usr/bin/python instead or (preferably) #!/usr/bin/env python .

+6
source

All Articles