update python3.6 to 3.9 ubuntu using terminal code example

Example 1: change python 3.5 to 3.6 ubuntu

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 --config python3

Example 2: how to upgrade python from 2.7 to 2.9 on ubuntu 14.04

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
 git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv