Update Alternatives in Debian

Debian can have multiple versions of the same application or even different applications of the same type. For example, there can be multiple text editors installed. If you want to pick a default application, update-alternatives is your friend. Run the command and a list should be displayed from which you make your selection. Here I will try to put commands which pick default entries for applications.

Choose default text editor: sudo update-alternatives --config editor

Change default Python version: sudo update-alternatives --config python

Sometimes you may get a message: No alternatives for python, if you try, say, update-alternatives --config python. You may then have to manually add all the executable versions to the update-alternatives system. For example, if you have both Python 2.4 and Python 2.5 installed, you may want to do something like:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.4 10
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.5 20

Now when you run sudo update-alternatives --config python you should be able to choose a default version. The numbers 10 (after 2.4) and 20 (after 2.5) indicate preference; higher the number, more preferred it is (at least the way I understand it).

8 Responses to Update Alternatives in Debian

  1. iE says:

    there is one issue still, you cannot install development headers for the current “chosen” python version

  2. merwok says:

    Hello

    The default editor, pager, mailer, etc. can be set on a machine thanks to the alternatives system. However, the default Python version is not meant to be changed by the sysadmin, it is chosen by the distribution. That’s why /usr/bin/python is a symlink to /usr/bin/pythonx.y, not a symlink managed by alternatives.

    Your own scripts can explicitly invoke the Python version you want; scripts provided by system packages depend on the system default version. Don’t muck with it.

    Regards

  3. Nathan Moos says:

    One tip: NEVER DO THIS with python3! NEVER make python3 your default python version. it will mess up your system.

  4. Pingback: 10 steps to get Python 2.5.x on Ubuntu Lucid Lynx (10.04) «

  5. ket says:

    great post

  6. Anonymous says:

    didnt work for me – no errors but default didnt change – the star is saved at python1.6 but 1.7 is still the default
    I am on ubuntu 10.4 – in installed 1.7 from source but 1.6 is the system default and has been written over by 1.7

  7. Éric Araujo says:

    I think you meant 2.6 and 2.7, not 1.6 :)

    See my message above: Python is *not* meant to be configured with the alternatives system. Don’t do it.

  8. Pingback: How can I install a debian package using specific version of python Deni How