Why use #!/usr/bin/env python rather than #!python?

Adriano Ferreira a.r.ferreira at gmail.com
Fri Dec 2 10:07:17 EST 2005


On 12/2/05, Carsten Haese <carsten at uniqsys.com> wrote:
> (3) assumes that whatever shell the user is running looks up the shebang
> executable in the path, which bash, just to name one example, does not
> do.

I think that was the answer I was looking for. So that "#!/usr/bin/env
python" is more portable than "#! python" and that's probably why it
worked for me with cygwin/bash but not for Klaus on whatever platform
he used.

> (2) and (1) require that you know where env and python live,
> respectively, that's true, but env is likely to be found in an
> OS-dependent standard location than python, so (2) is preferable.

I agree. Only a very strange Unix-like installation would not have
'env' at '/usr/bin/env'.

Many thanks to Klaus and Carsten for helping me find out why this
convention is helpful/useful.

Best regards,
Adriano



More information about the Python-list mailing list