Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I can access Python 3 via python3 command. But I want to make the default interpreter to use python command for Python 3. Simple typing python takes me to Python 2. How to upgrade?

share|improve this question
Just a warning: Do not attempt to change the /usr/bin/python symlink to point to python3 instead of 2.7. Many programs available in the Ubuntu repos require /usr/bin/python to be compatible to python 2.x. –  soulsource Jul 17 '13 at 8:17
@soulsource, yeah I'm aware of that. that's why i asked is there an "upgrade" option available or not. –  Giri Jul 17 '13 at 8:24
I think the answer by Radu Rădeanu is already quite close to the optimal solution. It only applies to one user, and is only in effect for directly running python typing the python command, not affecting programs with a #!/usr/bin/python shebang. –  soulsource Jul 17 '13 at 8:44
Ah, now I got what you meant with upgrade... Actually the Ubuntu developers are working on that: wiki.ubuntu.com/Python/3 "It is a release goal for Ubuntu 14.04 LTS to have only Python 3 on the desktop CD images." –  soulsource Jul 17 '13 at 8:45
@soulsource that's what I'm searching for! :) thanks! –  Giri Jul 17 '13 at 9:36

4 Answers 4

up vote 17 down vote accepted

A simple safety way would be to use an alias, by placing:

alias python=python3

into ~/.bashrc or ~/.bash_aliases file.


share|improve this answer
so no "upgrade" option..?? –  Giri Jul 17 '13 at 8:14
@Giri You said that you have python3. What for an upgrade? –  Radu Rădeanu Jul 17 '13 at 8:16
actually i want to wipe-out 2.7 and replace it with 3.3. Seems like its a bad idea for now.. –  Giri Jul 17 '13 at 8:26
+1 there is no reason to purge 2.7 in order to be able to work with 3.3. As lots of software still depends on 2.7; just keep it lingering around. –  don.joey Jul 17 '13 at 9:39
@begueradj An alias is totally different from a symbolic link. –  Radu Rădeanu Jun 3 '14 at 7:41

From the Ubuntu wiki:

For both Ubuntu and Debian, we have ongoing project goals to make Python 3 the default, preferred Python version in the distros.

What this does not mean:

  • /usr/bin/python will point to Python 3. No, this is not going to happen (unless PEP 394 advocates otherwise, which is doubtful for the foreseeable future). /usr/bin/python and /usr/bin/python2 will point to Python 2.7 and /usr/bin/python3 will point to the latest supported Python 3 version.

  • Python 2 will be removed from the archive. No, this is not going to happen. We expect Python 2.7 to remain supported and available in Ubuntu for quite a long time, given that PEP 373 promises upstream bug fix maintenance support until 2020.

It is not recommended to change the symbolic link because of other package dependencies, but they "have ongoing project goals to make Python 3 the default, preferred Python version in the distros".

For CLI use, like @Radu Rădeanu, I would recommend putting an alias in the user's ~/.bashrc, .bash_aliases file (the different files, including ~/.bash_profile, are all loaded together and are simply for organizational purposes).

Such as:

alias python=python3


alias python='/usr/bin/python3'

Scripts can then start with something like:

#!/usr/bin/env python

instead of


I would still recommend using #!/usr/bin/python3 in scripts for simpler cross-compatibility.

share|improve this answer

You can use update-alternatives to provide different versions of programs that may be needed at different times due to compatibility issues.

This answer Is a good example for how to set things up for simultaneously maintaining different versions of gcc/g++, for example.

just do the same with python2.7 and python 3.3

share|improve this answer
Beginning users may not be able to easily adapt the linked answer to a different situation. In addition to crediting the earlier answer, it would be good to lay out the steps needed for Python. –  chaskes Oct 18 '13 at 14:47

[Update: This is the wrong way, I have learned, since Python-2 and Python-3 are not really interchangeable.]

You can try the command line tool update-alternatives.

$ sudo update-alternatives --config python

If you get the error "no alternatives for python" then set up an alternative yourself with the following command:

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10

Change the path /usr/bin/python3 to your desired python version accordingly.

share|improve this answer
python2 and python3 are not alternatives. Do not use update-alternatives for this purpose. –  i08in Jun 2 '14 at 18:37

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.