Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Platform: Ubuntu 12.10

Python version installed: 2.7.3 (with ubuntu installation)

output of command (which python): usr/bin/python

recently i installed python2.6.6 (as some applications don't work on 2.7.3 version)

output of command (which python2.6): usr/local/bin/python2.6

by default command 'python' runs default version i.e 2.7.3

My requirement is to set python2.6.6 version to be the default one.


share|improve this question

migrated from stackoverflow.com Jun 18 '13 at 6:54

This question came from our site for professional and enthusiast programmers.

Possible duplicate: stackoverflow.com/questions/11756777/… –  djf Jun 17 '13 at 18:49
did you consider update-alternatives? –  njzk2 Jun 17 '13 at 19:26
@njzk2 yes i tried using update-alternatives but in that case I'm unable to import some modules which meant to be for version 2.7.x. In that case i wasn't able to even run pip command without errors. –  user2494535 Jun 17 '13 at 19:57
How to install modules to a specific version ?? –  user2494535 Jun 17 '13 at 19:57

4 Answers 4

up vote 0 down vote accepted

In Ubuntu I would shy away from just changing the sym-links. Looks like the new way of doing this is update-alternatives, or python-virtualenv if you want to go that route. Check the responses here:


share|improve this answer

You can do that with following command, but this could cause problems.

sudo ln -sf /usr/local/bin/python2.6 /usr/bin/python
share|improve this answer
what type of problems? –  user2494535 Jun 17 '13 at 19:54
Many program in ubuntu assume that python2.7 is default. And if some of that program use the features that initroduced in python2.7, that program will not work. –  falsetru Jun 18 '13 at 0:44

If you perform the command ls -al /usr/bin/python*, you should see some symbolic links redirecting python to the latest version of python (2.7.X, in your case). You can manually redirect this symlink to whichever version you like (2.6.X, in your case):

sudo ln -s /usr/bin/python2.6 /usr/bin/python
share|improve this answer

If you are using open sourced software i would suggest patching your problematic scripts with a version selector. Kinda:

#!/usr/bin/env bash
# Build some *.pyc scripts out of xsd schemas
./generate_all_ds.sh && # Uses xsd files to build the *.py sources to be compiled
 python --version 2> python_version.foo &&
 PYTHON_VERSION=`cat python_version.foo | sed -e 's/Python //'` &&
 rm -fv *.pyc &&
 echo Will now execute \'pycompile synthetic_data.py ... tracked.py -V $PYTHON_VERSION -v \&\&\' &&
 pycompile synthetic_data.py ... tracked.py -V $PYTHON_VERSION -v &&
 sleep .001 && # Sorry cant remember why, wouldnt surprise me not existing reason at all
 rm python_version.foo &&
 echo 'Compilation batchjob completed successfully'

If this does not show the big picture then just think about how to make programs that behave according to what interpreters does each particular host have.

This is somewhat old software, nowadays i would have done it asking for mktemp when using foofiles.

God help me now.

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.