#!/usr/bin/env python vs. #!/usr/bin/python

Jeroen Ruigrok van der Werven asmodai at in-nomine.org
Fri May 2 01:12:44 EDT 2008


-On [20080502 05:26], Ben Finney (bignose+hates-spam at benfinney.id.au) wrote:
>I've never clearly understood why people want to use "#! /usr/bin/env
>python", which is prone to finding a different Python from the one
>installed by the operating system. I'd be interested to see what
>responses are in favour of it, and what the reasoning is.

Simple, some systems are not as peculiar as a lot of Linux boxes which
chug everything into /usr/bin, which is OS territory (as has been decreed
long ago by hier(7)), but rather use /usr/local/bin (all BSD Unix and
derivatives) or /opt or whatever convention a particular operating system
has.

And prone to find the wrong Python, it all depends upon proper $PATH
administration.

As such, your script with #!/usr/bin/python is as bad as an ash shell script
with #!/bin/bash. #!/usr/bin/env python is more cross-OS friendly, there's
more than just Linux you know.

-- 
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B
I dream of Love as Time runs through my hand...



More information about the Python-list mailing list