Dealing with python version
Harry George
hgg9140 at seanet.com
Wed Mar 27 17:51:25 EST 2002
Andrei Kulakov <ak at silmarill.org> writes:
> Hello,
>
> Correct me if I'm wrong, but it seems like if python1.6 or 2.0 are
> already installed and you install a newer version, python command still
> points to the old interpreter.
>
> I think it would be sensible to use the newest installed python to run
> a program. Is there some elegant way to do that?
>
> I would ideally prefer it to run using newest interpreter available
> unless it's older than some minimum requirement. It's not very
> user-friendly to put #!/usr/bin/env python2.1 bang line and then say in
> a README that if user gets an error, he has to somehow find out what's
> the latest version he's got and change the bang line to it.
>
> What's the proper way to deal with all of this?
>
I'll assume *NIX, and more specifically Linux (because it has python
scripts scattered through the std installation). Typically, the
preinstalled scripts are expecting a specific version of python, and
expect to find it via:
#!/usr/bin/python
or
#!/usr/bin/env python
You don't want to screw up those preinstalled scripts, so don't do
anything to the original installation. Instead, install new version
elsewhere, e.g.:
/usr/local/bin/
python2.0
python2.1
/usr/local/lib/
python2.0
python2.1
Each installation will create a generic "python" binary (e.g.,
/usr/local/bin/python) as well as the versioned name. Delete the
generic one, so it doesn't interfere with the preinstalled python.
That leaves the problem of accessing the new ones. I use little
scripts:
/usr/local/bin
py20
py21
Where py20 is, e.g.:
#!/bin/sh
unset PYTHONHOME PYTHONPATH PYTHONLIB
/usr/local/bin/python2.0 "$@"
To use:
py20 myprogram.py
Can also start scripts with:
#!/usr/local/bin/python2.0
> Thanks,
>
> - Andrei
>
> --
> Cymbaline: intelligent learning mp3 player - python, linux, console.
> get it at: cy.silmarill.org
--
Harry George
hgg9140 at seanet.com
More information about the Python-list
mailing list