[Python-Dev] Support the /usr/bin/python2 symlink upstream

Toshio Kuratomi a.badger at gmail.com
Tue Mar 8 01:13:18 CET 2011


On Tue, Mar 08, 2011 at 08:25:50AM +1000, Nick Coghlan wrote:
> On Tue, Mar 8, 2011 at 1:30 AM, Barry Warsaw <barry at python.org> wrote:
> > On Mar 04, 2011, at 12:00 PM, Toshio Kuratomi wrote:
> >
> >>Actually, my post was saying that these two can be decoupled.  ie: It's
> >>possible to not have /usr/bin/python while still allowing users to type
> >>python at a shell prompt and get the interpreter.
> >>
> >>This is done by either redefining the PATH to include the directory that the
> >>interpreter named "python" is in or by creating an alias for python to the
> >>proper interpreter.
> >
> > I personally would prefer aliasing rather than $PATH manipulation.
> 
> Toshio's suggestion wouldn't work anyway - the "/usr/bin/env python"
> idiom will pick up a "python" alias no matter where it lives on $PATH.
> 
I thought I pointed out that env wouldn't work with PATH but I guess I just
thought that silently in my head.  Pointing that out was going to live in
the same paragraph as saying that it does work with an alias::

$ sudo mv /usr/bin/python /usr/bin/python.bak
$ alias python='/usr/bin/python2.7'
$ python --version
Python 2.7
$ cat test.py
#! /bin/env python
print 'hi'
$ ./test.py
/bin/env: python: No such file or directory
$ mv /usr/bin/python.bak /usr/bin/python
$ ./test.py
hi


-Toshio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110307/5815a1a1/attachment.pgp>


More information about the Python-Dev mailing list