Installing Python on Linux based operating systems can be done in a few simple steps.
Throughout this guide, we will be walking you through the process of installing Python to a couple of different Linux based distributions.
There are three primary package managers that we will be showing you how to use to install Python.
One of the most prominent package managers is APT, which is used by almost all Debian based systems such as Ubuntu, Raspbian, and Linux Mint.
The other two major package managers are YUM and DNF. Yum is primarily utilized by CentOS, and DNF is mainly used by Fedora.
To get started, we will walk you through installing Python to Debian based operating systems that make use of the APT package manager.
Installing Python on Debian Based Systems
Debian is a popular operating system that has spawned many offshoots such as Ubuntu.
Throughout this section, we will be showing you how to make use of its “APT” package manager to install Python to your Linux system.
You may need to do these steps if you need to install Python for a Raspberry Pi project you’re doing.
These steps will work on almost all Debian derived operating systems.
1. To get started, load up the terminal on your system.
We will need to use the terminal to use the APT package manager to install Python to your system.
2. With the terminal open, we should first update the available package list by running the following command.
Updating the list ensures that all downloads should still be available, and you won’t run into issues with APT trying to download a file that no longer exists.
sudo apt-get update
3. With the update now complete, we can proceed to install Python by running the command below.
As well as installing Python, we will also be installing “pip” which is a package management system for Python that you will come to use a lot.
In addition to pip, we will also be installing Python 3’s virtual environment module.
sudo apt-get install -y python3 python3-venv python3-pip
4. Now that we have installed Python to our Debian based Linux operating system, we can verify that it is now up and running.
To do this, we need to run the following command. This command will call Python 3 and get it to print out its version number.
5. If everything is working, you should now have the following text appear in your terminal session.
Please note that the version can differ as different Debian distributions may offer different versions of the Python 3 interpreter.
With that done, you should now have Python up and running on your Debian based operating system and can now proceed with learning Python.
Installing Python on Fedora
Fedora makes use of a different package manager to Debian. Instead of using APT, it makes use of a package manager called DNF.
We will be walking you through the steps to using DNF on your Fedora system to install Python.
1. The first thing we must do on your Fedora system is launch up the terminal.
We will be making use of this terminal session to use DNF to install Python to Fedora.
2. Within the terminal, enter the following command to install Python using the DNF package manager.
sudo dnf install python3 python3-pip python3-venv
3. With that done, Python should now be installed to your Fedora installation.
You can verify this by running the following command to retrieve the Python version.
4. If Python has been installed successfully, then you should see text like what we have below in your terminal.
If you can see the text, then you have successfully installed Python to your Fedora system.
Installing Python on CentOS
In this section of our installing Python on Linux guide, we will be walking you through the steps of installing Python on a CentOS system.
Installing Python to CentOS is a reasonably straightforward process and is much like installing Python on Debian based systems or Fedora.
1. Before we install Python on CentOS, the first thing we must do is update “yums” package list
We can update the package list by running the command below.
sudo yum update
2. Now that we have updated the package list, we can now proceed to install Python 3, and it’s pip module to CentOS.
To install all of these, you can run the following command.
sudo yum install python3 python3-pip python3-venv
3. Now with Python installed to our CentOS system, we can now verify its working by running the following command.
4. If everything is working as intended, then you should see the following in your terminal..
The version text will differ depending on the version of Python 3 being served by your chosen distribution.
Hopefully, at this point in the guide, you will now have Python installed to your Linux distribution.
You can now safely proceed onward with our getting started with Python guide.
If you need any help or have any feedback, then feel free to leave a comment below.