Is there a particular reason on why
update-alternatives is not working with
Python since ubuntu comes bundled with different versions?
The reason is,
python versions aren't fully compatibile. If you set
3.3 version as your default, the applications made for
2.7 could not work.
Or maybe you can.
Important Note: The solution presented bellow (with
update-alternatives) may break your system.
If things break, try to fix them and keep python 3, report the fix you made to the correct bug-reports sites and help the community to grow; or move back to python 2. At the end of the answer I'll add a simple command to move back in case you need.
If you just want to change python for your own user, not the system, you can use an alias.
Solution 1: alias
Add this line into your
And that is it. You don't need to read bellow.
Solution 2: update-alternatives
If alias is not what you are looking for, and you really want to change the default of the whole system, then keep reading.
First check your python version:
# python -V Python 2.7.13
Use this commands to install alternatives (run as
root or use
# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 # update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
Then configure the version with (again, run also
root or use
$ sudo update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.5 2 auto mode 1 /usr/bin/python2.7 1 manual mode 2 /usr/bin/python3.5 2 manual mode Press <enter> to keep the current choice[*], or type selection number: 2
Now check the version:
# python -V Python 3.5.3
When you run the above command, you can choose
selection number: 0 or
2 to pick python 3. If things break, run again and pick number
1 to go back to python 2.