env: python\r: No such file or directory
Post by
on June 20, 2012Recently I attempted installing phpsh for the fun of it and lo and behold, yet another Python issue. I love Python, and the issue ended up not being Python's fault... I suppose it is simply a frustration at not being familiar with the language. All that said, here is how to fix the "No such file or directory" issue, using phpsh as an example.
To give some context, I am using Snow Leopard (Mac OS X 10.6.8) and have not made any changes to the default install of Python (except installing Xcode, if that has any effect).
So, I install dependencies:
$ sudo easy_install readline $ sudo easy_install pysqlite
And then build and install phpsh:
$ sudo python setup.py build $ sudo python setup.py install
Then, I go to run it:
$ phpsh env: python\r: No such file or directory
Ok, so I figured I would check the file to see if it is a simple bash or python script, and I see:
#!/usr/bin/env python
I did a bit of trial and error to no avail and result to Google where I come upon Ignacio Vazquez-Abrams' response on StackOverflow to use dos2unix, implying that the issue is the line endings.
I already had dos2unix installed, but if you don't and you have ports installed, simply run:
$ sudo port install dos2unix
So, I run dos2unix on the file:
$ sudo dos2unix /usr/local/bin/phpsh dos2unix: converting file /usr/local/bin/phpsh to Unix format ...
Tada! It now works!