Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a machine with Python 2.6 installed as the default Python. Then, I installed Python 2.7, and manually created /usr/bin/python as a symlink to the new installation.

Then, I was running into problems with command-not-found. I'm trying to reinstall it:

sudo apt-get remove command-not-found

and I get this error:

/usr/bin/python does not match the
python default version. It must be
reset to point to python2.6

But I really want Python 2.7 to be the default. How do I fix this mess?

share|improve this question
up vote 11 down vote accepted

Changing the default Python (or Perl, etc) on an OS is really bad idea. This interpreter is actually part of the OS and there may well be other OS components that are written specifically to work with that version of the interpreter.

For example on Redhat the yum tool that performs system software updates is a python application. You really don't want to break this. Such applications may depend on specific, perhaps non standard, python modules being installed which the version you installed may not have. For example on Ubuntu I believe some of the built-in OS tools written in Python use an ORM called Storm that isn't part of the Python standard library. Does your clean Python 2.7 install have the specific expected version of the Storm module installed? Does it have any version of Storm? No? Then you've just broken a chunk of your OS.

The right way to do this is install your preferred version of python and set up your user account to use it by setting up your .bash_profile, path and such. You might also want to look into the virtualenv module for Python.

share|improve this answer
+1 for virtualenv – Hauke Jul 23 '12 at 12:31
Googled my way here. Would -1 if I had the rep on this stack. Why? Because the suggested approach says only "install your preferred version of python". How is that done without hosing the system python? – jez Dec 16 '15 at 21:45

How do I fix this mess?

Nothing more than reinstalling python. It will undo your change (the symlink).

Why do you want it as default? Each time you need it, just use python2.7 or include #!/usr/bin/python2.7 (the shebang) at the beginning of your (executable) scripts.

If you insist on having python2.7 as system-wide default, use a later release of Ubuntu (currently it's Ubuntu 11.04, codenamed Natty). It uses that version as default.

In future, avoid doing manual interventions like what you did with the symlink thing. This is especially true for distro-managed files, and most especially for complex beasts like Python installations.

share|improve this answer
I thought that it's only reasonable to change the default python installation once I upgraded. I want it as default because I want to work with the newer python ... as default. When I type python from bash, I want to get the new python. Is there a better way to do this than what I did? – ripper234 Mar 20 '11 at 8:18
Just to note - I don't think there was anything wrong in the way I installed python 2.7. The only "unorthodox" move was changing the symlink, which I thought was the proper way to set it as default. Is there a better way? – ripper234 Mar 20 '11 at 8:19
@ripper: I guess I'm coming to this thread a little late. As Tshepang says the python package on Ubuntu determines the system version. Now, it is possible to customize your installation so python 2.7 is default by creating your own python package etc, but if so, you'll effectively be becoming maintainer of your Python installation instead of Ubuntu, and you'll have to learn how Python is managed on Debian/Ubuntu. Bear in mind that the other Python packages in the system are configured to work with 2.6 as default, so, apart from anything else, breakage may result. – Faheem Mitha Mar 20 '11 at 8:56
@Tshepang: Good summary! – Faheem Mitha Mar 20 '11 at 9:23
@ripper234: Don't change anything in /usr/bin, that's reserved for your distribution. Instead, make /usr/local/bin/python a symbolic link to python2.7. Then scripts using #!/usr/bin/env python (the recommended idiom), as well as typing python on the command line, will run Python 2.7. Scripts from the distribution that want the Python from the distribution can keep calling #!/usr/bin/python. – Gilles Mar 20 '11 at 13:22

We put multiple python distributions on Mac and Ubuntu a lot and here are my recommendation.

  1. Leave the system python unmolested: never use it.

  2. If you only need one primary python distribution, download and install Canopy from enthought. When it installs, choose "set as my system python", and then you can install packages from Canopy's GUI package manager.

    • Canopy is also compaitble out of the box with pip, the PyPi package manager command that lets you install packages (eg pip install python-twitter)
  3. If you plan to use virtual environments (ie you are developing python programs and want a dedicated clean python environment for each, with an easy means to switch between them), I'd recommend Anaconda over Canopy due for it's virtual environment manager tool. This will let you
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.