a list of ways to install Python (*nix) (was: 'python' Bash command doesn't link to 2.1.1)
Bruce Sass
bsass at freenet.edmonton.ab.ca
Thu Aug 16 03:44:45 EDT 2001
On 15 Aug 2001, Harry George wrote:
> Richard Jones <richard at bizarsoftware.com.au> writes:
> > On Tuesday 14 August 2001 10:23, root wrote:
> > > Hello, I've decided to use Python as my first programming language (as
> > > per advice at http://www.tuxedo.org/~esr/faqs/hacker-howto.html ) and
> > > I've run into a problem during installation.
> >
> > Marvellous idea :)
> >
> > > I cannot, however, run Python 2.1.1 using the 'python' terminal command
> > > and there is no Python man page installed. Typing 'python' at the
> > > command prompt brings up the 1.5.2 interpreter. I can run the 2.1.1
> > > interpreter by typing the path of the toplevel Python directory and then
> > > /python (e.g. /home/root/Python-2.1.1/python) but I don't want to have
> > > to do this every time I start the interpreter and I would also like to
> > > have the man page installed.
> >
> > By default, python will be installed to /usr/local/bin. Your system will have
> > python 1.5.2 installed in /usr/bin. That binary will be found first when you
> > type "python" at the command line. To force using python 2.1.1, run
> > "/usr/local/bin/python".
> >
> > Or, do the following (as root):
> >
> > cp /usr/bin/python /usr/bin/python1.5
> > cd /home/root/Python-2.1.1/
> > make distclean
> > ./configure --prefix=/usr
> > make install
>
> An alternative, allowing you to run several different verisons of
> python:
>
> as root edit a file "/usr/local/bin/py21":
> #---edit------------
> export PYTHONHOME=/usr/local
> export PYTHONPATH=${PYTHONHOME}/lib/python2.1:${PYTHONHOME}/lib/python2.1/site-apckages
> ${PYTHONHOME}/bin/python2.1 $@
> #---end edit-----------
> and do
> chmod +755 py21
>
> Then you can run python 2.1 stuff with "py21" and python 1.5.2 with
> "python". This may be important if some system scripts depend on one
> version or the other.
>
> > the --prefix=/usr tells the install to place python in /usr/bin (and the
> > library files will go in /usr/lib/python2.1). Note, you'll want to remove the
> > "other" python2.1 installation too (/usr/local/bin/python and
> > /usr/local/lib/python2.1). The first command above just keeps the old python
> > around just in case you need it in the future.
> >
> > Then you will be able to run "python" at the command prompt and get 2.1.1 :)
I've found this works well:
- PYTHON{HOME,PATH} are unset, Debian's site.py also adds
/usr/local/... to PYTHONPATH
- interpreters installed as bin/python<major>.<minor>
- /usr/bin/python is a link to the system's default Python
- /usr/local/bin/python -> maybe what I want as the default Python
- executable scripts in Tools/... get rewritten so that:
"bin/python" disappears and "env python" uses the proper
python<maj>.<min> (see Tools/scripts/fixps.py), then installed
with a -<version> suffix and the same bin vs. local/bin game
as with the interpreters
[only for local stuff, Debian looks after /usr/{bin/lib}]
- $HOME/.pythonrc.py sets up the interactive environments
Toss in whatever shortcut files and menu entries your system supports
(system, KDE, Gnome, etc., don't use absolute paths to the
executables) -- it is very easy to select which interpreter/idle/etc.
to use from menues, or between the local and system defaults with a
few symlinks. I have been caught once, when local/bin/python pointed
to a Python a system script didn't work with (and I think it was a
packaging error), but that may only be because Python has been pretty
good at being backwards compatible.
- Bruce
More information about the Python-list
mailing list