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:
$ ./manage.py 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 manage.py 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 manage.py
dos2unix: converting file manage.py to Unix format...
And just like that, I can now run the file directly without it ever complaining that it can’t find Python.