Thursday, December 5, 2013

Bad Interpreter Error

I recently tried to run a Python script on one of my Linux boxes and received the following error.

"bash: ./count.py: /usr/bin/python^M: bad interpreter: No such file or directory"

What I discovered is that this happens when you create a script on Windows, which I had done, and then try to run it on Linux.  However, this is an easy problem to solve.

Run the dos2unix command against the file and your scripts should function correctly.

"dos2unix filename"