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

Klaus Alexander Seistrup klaus at seistrup.dk
Fri Dec 2 10:12:48 EST 2005


Adriano Ferreira wrote:

> 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.

/me is using bash on linux.

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

According to <http://www.in-ulm.de/~mascheck/various/shebang/>:

  »However, env(1) is not /usr/bin/env but /bin/env at least on 
   Unicos 9.0.2, OpenServer 5.0.6 and IIRC on at least one older 
   Linux distribution. Free-, Net- and OpenBSD in turn only come 
   with /usr/bin/env. So the env-mechanism is increasing conven-
   ience, but not strictly assuring portability.«

Cheers,

-- 
Klaus Alexander Seistrup
PNX · http://pnx.dk/



More information about the Python-list mailing list