Note to self: “env: python\r: No such file or directory” error

On one of the Python project we are handling at work, it always spit up this error when we try to directly run the .py file:

$ ./ runserver
env: python\r: No such file or directory

At first I thought it was that my PATH is botched up. But the other Python apps are running perfectly fine.

Upon reading about, I found out that it is actually caused by irregular line-break ending of the file. This can be easily fixed by using a nifty utility called dos2unix.

Since I’m using OSX with HomeBrew installed, I can do the following:

$ brew install dos2unix
$ dos2unix
dos2unix: converting file to Unix format...

And just like that, I can now run the file directly without it ever complaining that it can’t find Python.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.