Welcome, Linux enthusiasts! In Post #2 and Post #3, we covered the Python installation process for Windows and macOS. We now arrive at the final operating system in our setup trilogy: the powerful and versatile world of Linux.
Most Linux distributions come with Python pre-installed, as it’s a critical part of the system itself. However, this pre-installed version is often not the latest, and you should avoid using the system’s Python for your own projects to prevent potential conflicts.
This guide will walk you through installing a modern, separate version of Python 3 on the two most popular families of Linux distributions: Debian/Ubuntu and Fedora/RHEL.
Step 1: Check Your Current Python Version
First, let’s see what version of Python 3 is already available on your system. Open your terminal and type the following command:
python3 --version
This will likely show a version like Python 3.8 or 3.10. While functional, our goal is to install the latest stable release to take advantage of new features, performance improvements, and security updates, without interfering with the version your system depends on.
Step 2: Install Python 3
The installation process varies slightly depending on your distribution’s package manager. We’ll cover the two main ones below.
For Debian, Ubuntu, and derivatives (using APT)
These systems use the apt
package manager. To get the most up-to-date versions of Python, the community-trusted deadsnakes
PPA (Personal Package Archive) is the recommended source.
First, update your package list and install a prerequisite:
sudo apt update
sudo apt install software-properties-common
Next, add the deadsnakes
PPA to your system’s software sources. Press Enter when prompted to confirm.
sudo add-apt-repository ppa:deadsnakes/ppa
Finally, after adding the PPA, you can install the latest Python version. We’ll use Python 3.12 as an example:
sudo apt install python3.12
For Fedora, RHEL, and CentOS (using DNF)
These distributions use the dnf
package manager (or yum
on older versions). Their official repositories are typically very up-to-date.
First, ensure your system’s packages are current:
sudo dnf update
Now, you can install the latest available Python package directly.
sudo dnf install python3
This command will install the latest stable version of Python 3 supported by your distribution’s repositories.
Step 3: Install Pip and Venv
Unlike the installers for other operating systems, on Linux, pip
(the package installer) and venv
(for creating virtual environments) are often handled as separate packages. It’s crucial to install them for the specific version of Python you just set up.
For Debian, Ubuntu, and derivatives
Install pip
and venv
that correspond to the Python version you installed (e.g., 3.12):
sudo apt install python3.12-pip python3.12-venv
For Fedora, RHEL, and CentOS
The package names are slightly different here. You will want to install python3-pip
and python3-devel
, which includes the necessary components for venv
.
sudo dnf install python3-pip python3-devel
Step 4: Verify Your Installation
Let’s make sure everything is working as expected. Open a new terminal window to ensure the session is updated.
Check the version of your newly installed Python interpreter. Note that we are being specific and calling python3.12
directly.
python3.12 --version
You should see the exact version you installed:
Python 3.12.0
Next, do the same for pip
, using the version-specific command:
pip3.12 --version
This should confirm the pip
version and that it is linked to your new Python 3.12 installation. Using these version-specific commands (python3.12
, pip3.12
) is the most reliable way to ensure you are not accidentally using the system’s default Python.
What’s Next?
Congratulations! Your Linux machine is now set up with a modern version of Python, ready for serious development.
With setup guides for Windows (Post #2), macOS (Post #3), and now Linux complete, we have officially prepared our development environments. The setup phase is over! In our next post, Post #5, we will finally unite and write our very first line of Python code. It’s time for the classic “Hello, World!”.
Author

Experienced Cloud & DevOps Engineer with hands-on experience in AWS, GCP, Terraform, Ansible, ELK, Docker, Git, GitLab, Python, PowerShell, Shell, and theoretical knowledge on Azure, Kubernetes & Jenkins. In my free time, I write blogs on ckdbtech.com