Install Python on Ubuntu or Any Other Linux Distro

Ubuntu provides a seamless and straightforward way to install Python, allowing you to quickly get started with coding.

Install Python on Ubuntu or Any Other Linux Distro
Image by Growtika / Unsplash

Python is a powerful and versatile programming language that is widely used in various fields, such as web development, data analysis, and artificial intelligence.

Python enthusiasts love using Ubuntu and other Linux distributions because these operating systems provide a seamless and efficient development environment for Python programming, with their robust command-line interface, extensive package management systems, and strong community support.

Ubuntu and other Linux distributions are known for their stability, security, and flexibility, making them an ideal choice for Python programmers who value reliability and customization. The open-source nature of Linux also aligns well with the Python community's ethos, fostering collaboration and innovation.

How to Install Python on Ubuntu or Any Other Linux Distro

In this tutorial, we'll guide you through the step-by-step process of installing Python on Ubuntu, so you can begin your Python journey with ease. So, let's dive in and get Python up and running on your Ubuntu machine!

Ubuntu comes with a pre-installed version of Python. However, installing Python manually gives you more control over the Python environment and allows you to install additional packages as needed.

To see which version of Python 3 you have installed, open your terminal and run

  python3 --version

If, however, you are using an older version of Ubuntu or have just performed a fresh installation, you can easily install Python 3.11 by using the following commands:

sudo apt-get update
sudo apt-get install python3.11

If you are using a different version of Ubuntu (such as the latest LTS release) or if you prefer to use a more recent version of Python, we suggest using the deadsnakes PPA to install Python 3.11.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.11

If you are using any other Linux distribution, it is possible that Python 3 is already pre-installed. If not, you can use your distribution's package manager. For instance, on Fedora, you would use dnf.

sudo dnf install python3

Note that if the version of the python3 package is not recent enough for you, there may be ways to install more recent versions as well, depending on your distribution. For example, you can install the python3.11 package on Fedora 32 to get Python 3.11. If you are a Fedora user, read about the multiple Python versions available in Fedora.

Working with Python 3

Once you have installed the latest version of Python, you can launch the Python 3 interpreter by using the following command in the terminal.


This command always launches the Python 3 interpreter.

Python 3 Setuptools & Pip

The two most crucial third-party Python packages are setuptools and pip.

command -v pip3

Once installed, you can easily download, install, and uninstall any Python software product using just one command. It allows you to easily incorporate this network installation feature into your own Python software with minimum effort.

To check if pip is installed, run the following command in your terminal:

Please note that on certain Linux distributions, such as Ubuntu and Fedora, the pip command is intended for Python 2, while the pip3 command is intended for Python 3. However, when working with virtual environments, you do not need to worry about this distinction.

To install pip, follow the official pip installation guide - this will automatically install the latest version of setuptools.

If you are familiar with Python, the next step for you may be to install Pipenv. This will allow you to install dependencies and manage virtual environments, keeping the dependencies required by different projects in separate places. By creating virtual Python environments for them, you can ensure that each project has its own isolated environment. You can refer to the Pipenv & Virtual Environments documentation to learn more.