How do I install Python 3.9? [duplicate]
I want to install Python 3.9 in Ubuntu. When I run sudo apt-get python
in the terminal it says that it will install Python 2 which I don't want. When I type sudo apt-get install python3.9
it shows that it is an invalid operation.
How do I install Python 3.9?
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:
You'll be asked if you want to continue. Press Enter to do so.sudo add-apt-repository ppa:deadsnakes/ppa
- Update
apt
again:sudo apt update
- Install Python 3.9:
sudo apt install python3.9
- Confirm that the installation was successful:
You should see:python3.9 --version
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.
Install synaptic using
sudo apt update
sudo apt-get install synaptic
Then, open synaptic and click on search button. Type "Python 3.9" and press Enter. Now click on the box next to python3.9 and click on mark for installation. On top click on Apply button.