I am hoping to be able to switch between python3.8 and python3.7 and also newer versions of python. For now how do I get the system default python version set to python3.7? I thought it is done with update-alternatives. I am running ubuntu 20.04.4
Any help is welcome.
Cheers
❯ 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.8 5 auto mode
* 1 /usr/bin/python3.7 4 manual mode 2 /usr/bin/python3.8 5 manual mode
Press <enter> to keep the current choice[*], or type selection number: ^C
❯ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 24 May 14 05:37 /usr/bin/python -> /etc/alternatives/python
❯ ssh noah@192.168.122.1
❯ 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.8 5 auto mode
* 1 /usr/bin/python3.7 4 manual mode 2 /usr/bin/python3.8 5 manual mode
Press <enter> to keep the current choice[*], or type selection number:
❯ which python
python: aliased to python3
❯ whereis python
python: /usr/bin/python2.7 /usr/bin/python /usr/bin/python3.8-config /usr/bin/python3.7m /usr/bin/python3.7 /usr/bin/python3.8 /usr/lib/python2.7 /usr/lib/python3.9 /usr/lib/python3.7 /usr/lib/python3.8 /etc/python2.7 /etc/python3.7 /etc/python3.8 /usr/local/lib/python2.7 /usr/local/lib/python3.7 /usr/local/lib/python3.8 /usr/include/python3.8 /usr/share/python
❯ ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 9 Mar 13 2020 /usr/bin/python3 -> python3.8
❯ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL=""
SUPPORT_URL=""
BUG_REPORT_URL=""
PRIVACY_POLICY_URL=""
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal 1 Answer
Even if update-alternatives work, do not change the default version of python. It may break your system.
It may be better to use alias in bashrc
open $HOME/.bashrc in a text editor and append
alias python=python3.7This will change the python version on your terminal only and should not affect system programs that depend on it.