0

I'm trying to make a python script runnable, by adding the following "shebang" first line:

#!/usr/bin/env python

but when I run the file, I get:

$ myscript.py
: No such file or directory

Now, if I just try the env line directly, it works:

]$ /usr/bin/env python
Python 2.6 (r26:66714, May  5 2010, 14:02:39)
etc. etc.

Why is the same line failing inside the file, but succeeding outside of it?

einpoklum
  • 9,515

1 Answers1

1

You probably have an invalid character somewhere in your shebang line. Since you're the one who inserted it, it's likely a carriage-return, i.e. your line ends with a newline and a carriage return (or vice-versa) - in the ODS style of line breaking.

Try using dos2unix on your script file to convert all the line breaks to only be 0x10 (UNIX-style).

einpoklum
  • 9,515