In Easy Steps Articles

February 9, 2023

How do I install Python on Linux?

Python is a powerful and versatile programming language that has become a staple in the software development industry. Its ease of use, broad range of applications, and a large community of developers make it an excellent choice for both beginners and experienced programmers alike.

For those looking to install Python on their Linux system, the process is straightforward and can be accomplished in a few simple steps.

In this tutorial, we’ll walk you through the process of installing Python on Linux, including checking if it’s already installed, updating your system, and choosing the best method for your needs.

Note: we have a full range of coding books for beginners, including JavaScript, Visual Basic, C Programming, and lots more!

Prerequisites to installing Python on Linux

Before you go ahead and install Python, you should take a few moments to check the system requirements and make sure that your machine is compatible. Python requires a relatively current version of a Linux operating system. If you’re running something older than CentOS 6 or Ubuntu 14, then you should update your OS before attempting an install.

It’s also worth noting that certain versions of Linux may require additional setup before Python will work. For example, Debian/Ubuntu-based distributions typically need to have Python’s build-essential package installed before they can use it.

In addition, you should also make sure that you have the necessary permissions to install Python on your system. If you are using a shared server, you may need to contact your system administrator to get the necessary permissions.

Installation Method 1: Using Package Managers

The easiest way to get Python up and running on your Linux machine is by using the package managers. These come bundled with your OS. In most cases, this involves running a single terminal command which will automatically download and install the most recent version of Python for you.

On Ubuntu/Debian, you would use APT like this:

sudo apt updatesudo apt install python3 

On CentOS/Red Hat, you need to use yum:

sudo yum update sudo yum install python3 

Note: The command “…install python3” will install the latest version of Python3 available in the Ubuntu/Debian or the CentOS/Red Hat repository. If you want to install a specific version, you can specify it by running the command “sudo apt install python3.x” where “x” is the desired version number.

Installation Method 2: Using source code

If you’d prefer to have more control over which version of Python you’re running, then you can compile it from source by downloading the source code tarball from This is a little more complex than using the package manager, but is preferable if you need to run a version of Python that isn’t available in the package manager or if you just want to be sure that you’re using the official version.

Once the tarball has been downloaded, unpack the tarball and cd into the directory. You then need to run the configure script which prepares the build environment. After that has finished, you can use make and make install to finally compile and install python.

You should always check the version of Python you are running to ensure that it is the correct version. Additionally, you should always check for any security updates or bug fixes that may have been released since the version you are running was released.

A step-by-step guide to install Python on Linux

If you’d rather have a step-by-step guide for installing Python on Linux, then follow these instructions instead:

  • Step 1. Open a terminal window on your Linux machine.
  • Step 2. Check if Python is already installed by running the command “python3 -V”.
  • Step 3. If Python is not installed, update your system by running the command “sudo apt update” (for Ubuntu/Debian), “sudo dnf update” (for Fedora/Red Hat), or “sudo zypper update” (for SUSE/OpenSUSE).
  • Step 4. Install Python using a package manager by running the command “sudo apt install python3” (for Ubuntu/Debian), “sudo dnf install python3” (for Fedora/Red Hat), or “sudo zypper install python3” (for SUSE/OpenSUSE).
  • Step 5. Alternatively, download the latest version of Python from the official website.
  • Step 6. Extract the source code using the command “tar xvf Python-3.x.x.tar.xz”.
  • Step 7. Enter the extracted directory and run the commands “./configure”, “make”, and “sudo make install”.
  • Step 8. Update the PATH variable by running the command “export PATH=”$PATH:/usr/local/bin”.
  • Step 9. Verify the installation by running the command “python3 -V” to check the version and “python3” to start the Python interpreter.
  • Step 10. You are now ready to start using Python on your Linux machine!

Key takeaways

  • Python is a versatile programming language that can be easily installed on Linux systems.
  • Before installing Python, it is important to check if it is already installed and update your system.
  • There are two main methods for installing Python on Linux: using package managers and using source code.
  • The process of installing Python using source code involves downloading the source code, building and installing it, and updating the PATH variable.
  • Once Python is installed, you can verify the installation by checking the version and running the Python interpreter.

Ready to learn more?

Python by In Easy Steps is your guide to mastering the Python programming language, even if you have no prior programming experience. This beginner-friendly guide is perfect for those who are new to coding, transitioning from another programming language, or studying Python in school or college. If you’re looking to start a career in computing, this guide will provide you with a solid foundation in computer programming.”

Check it out today!

Sign up to our


Our newsletters inform you of new and forthcoming titles, handy tips, and other updates and special offers. You can opt out anytime.

"*" indicates required fields

By Kieran Knight