3

I am running ubuntu 16.04. Recently I have installed python3.7.3 by running these commands:

sudo apt update



sudo apt install software-properties-common



sudo add-apt-repository ppa:deadsnakes/ppa

sudo apt update 
sudo apt install python3.7

after running these commands I typed:

python3.7

it says:

Python 3.7.3 (default, Mar 26 2019, 01:59:45) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.

But the default python in ubuntu still is python3.5. To configure it I am ran the following command in the terminal:

sudo update-alternatives --config python

the output of the command is as follows:

There is only one alternative in link group python (providing /usr/bin/python): /usr/bin/python3.5 Nothing to configure.

Any help to resolve this issue is highly appreciated.

Thanks in advance.

1
  • It seems generally a bad idea to change the Python where the system depends on, as I experienced it. In short, gnome-terminal did not start any more, and I could not solve it for my Ubuntu 18.04. See [stackoverflow.com/questions/56218562/… thread) for details. I ended up reverting the changes to the alternatives, and used Python3.8 for the application only.
    – domih
    Commented Mar 16, 2021 at 21:21

1 Answer 1

4

After install Python 3.6.x and/or 3.7.x you need to make python3 use the new installed python instead of the default 3.5 release.

Run following commands to add the alternatives:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 3

Then you can switch between the python versions for python3:

sudo update-alternatives --config python3

BUG: There is a bug for this method: gnome-terminal won’t launch after switch to newer version.

To solve this, you need to recreate the symlink:

sudo rm /usr/bin/python3

sudo ln -s python3.5 /usr/bin/python3

Check version with:

python3 -V
1
  • To avoid the error, you can use an alias: alias python3='/usr/bin/pytho3.6' Then re-login and check version: python --version
    – Marcelo
    Commented Oct 21, 2019 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .