I'm running Ubuntu to compile a set of code which requires python 2.4.
How can I setup a terminal launcher so that when I open that launcher all python related commands will use python 2.4 instead of th开发者_Go百科e python 2.6 that is defaulted in Ubuntu?
Set a bash
alias in that shell session: alias python=python2.4
(assuming python2.4 is in your $PATH of course). This way you won't have to remember to explicitly type the 2.4
a zillion times in that terminal -- which is what bash aliases are for!-)
Invoke the interpreter via python2.4
instead of using the default.
For a permenant system wide change put a symbolic link to the version you want in place of /usr/bin/python. ie
rm /usr/bin/python;
ln -s /usr/bin/python2.4 /usr/bin/python
gentoo has a program 'eselect' which is for just this kind of thing (listing versions of programs and setting the default), Ubuntu may have something analogous; you'd have to check their docs.
Watch out for using the alias when wanting to use the python you want. If the python script uses $0 to figure out, how it was called, then uses that answer to execute another python script. The other script will be called with whatever version that matches the link name, not the version the link points to.
精彩评论