What does "#!/usr/bin/env python" do?

Parzival ConfuseYourSpamBot-parzp at ConfuseYourSpamBot.shaw.ca
Mon Nov 10 03:22:07 EST 2003


nospam wrote:

> Since env is (almost?) always in /usr/bin, while python can be installed
> God-knows-where, that is more portable than writing #!/local/bin/python
> or #!/usr/bin/python or whatever.

That clarifies that! Thanks.

Followup question: I am using Mandrake 9.1, and it installs Python 2.2. I
have installed Python 2.3. Somewhere I read that Mandrake NEEDS Python 2.2
to work, I cannot just remove it, nor can I replace it with 2.3, as this
might be incomptible with some Mandrake Python script requirements.

It further tuns out that I have no control over the placement of entries
in PATH, so that my .bash_profile login script which adds /usr/local/bin to
the PATH, wherein are "python", "python2.3" and "idle", does not have
precedence over the Mandrake installed /usr/bin, wherein are "python" and
"idle". The result is that I must type "python2.3 myscript.py" or
"/usr/local/bin/idle myscript.py", and the just explained "#!/usr/bin/env
python" at the start of scripts always resolves in favour of the Mandrake
installed Python, not my own current version.

I would like my personal installation of Python to be the default and
convenient version, i.e. "./Myscript.py" "python MyScript.py" and "idle"
should resolve that instead of the system version. Is there a good way to
accomplish this?
 

-- 

(-: Stop, smile, and enjoy your breathing :-)
-- Parzival
-- Reply-to is confuggled: parzp (@) shaw (.) ca





More information about the Python-list mailing list