As you're "new to Linux", I won't suggest compiling from source. Instead, there is a PPA that you'll need to add to apt
so that you can use 3.9. Here are the steps:
- Open Terminal (if it's not already open)
- Update
apt
and confirm that you have the prerequisites installed:
sudo apt update
sudo apt install software-properties-common
- The PPA you'll need to add is maintained by "deadsnakes", so let's add that:
sudo add-apt-repository ppa:deadsnakes/ppa
You'll be asked if you want to continue. Press Enter to do so.
- Update
apt
again:
sudo apt update
- Install Python 3.9:
sudo apt install python3.9
- Confirm that the installation was successful:
python3.9 --version
You should see:
Python 3.9.1+
That's all there is to it. When you use anything that specifically requires Python 3.9, be sure to use python3.9
as the command, not python
or python3
.
Warning: Do not remove the default version of Python(3.x) which was preinstalled in Ubuntu, even if you install Python 3.9. Removing the default python version may break your system.