Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

: bad interpreter: No such file or directory in python [closed]

Tags:

python

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

bad interpreter: No such file or directory

Please tell how to resolve this error.

like image 377
Deepak Avatar asked May 26 '13 08:05

Deepak


2 Answers

Probably you have \r\n line endings, where \r is carriage return and \n is newline

That means that the first line might be like this

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

or

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

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

like image 101
John La Rooy Avatar answered Oct 18 '22 05:10

John La Rooy


You're probably using the #!python hashbang convention that's inexplicably popular among Windows users. Linux expects a full path there. Use either #!/usr/bin/python or (preferably) #!/usr/bin/env python instead.

like image 24
Cairnarvon Avatar answered Oct 18 '22 05:10

Cairnarvon