This quick tutorial is for those who want to install the latest Python 3.7.2 in Ubuntu 18.04 LTS, Linux Mint 19.x, and Ubuntu 18.10.
Ubuntu 18.04 comes with Python 2.7 and Python 3.6 out-of-the-box, and later includes Python 3.7.1 in its updates (universe) repository.
For the updated Python 3.7.2, you can do following steps to use the ToolChain PPA packages.
1. Open terminal either via Ctrl+Alt+T keyboard shortcut or by searching for “Terminal” from app launcher. When it opens, run command to add the ToolChain PPA:
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
Type user password (no visual feedback) when it asks and hit Enter to continue.
2. Then run command to install Python3.7:
sudo apt install python3.7
For Linux Mint 19.x, run command sudo apt update
to check updates first.
3. As the PPA contains other updates toolchain packages, e.g., gcc-7.4.0, gcc-8.2.0, and python-3.6.8, you may remove the PPA afterwards via Software & Updates -> Other Software tab.
4. To make python3
use the new installed python 3.7.2 instead of the default 3.6.7, run commands to add python3.7 as choice:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
Then switch between the two versions via command:
sudo update-alternatives --config python3
That’s it. Enjoy!