Skip to content
Follow
Ubuntu Linux

How to Install Python on Ubuntu Linux

Richard
Written by
Richard
Sep 26, 2021 Updated Jul 14, 2026 3 min read
Enable Automatic Suspension in Ubuntu Linux Easily
Enable Automatic Suspension in Ubuntu Linux Easily

Installing Python on Ubuntu Linux gives you a powerful programming tool for many computer tasks.

Python is a high-level programming language that’s easier for people to read and write. It lets you build websites, analyze data, and much more with its many built-in tools and add-ons.

This guide shows you how to install Python 3.10 on Ubuntu 22.04 LTS. This version is stable and current for your projects.

You can install Python using Ubuntu’s own software sources, which is the easiest way, or compile it yourself for more control over the newest features.

⚡ Quick Answer

You can install Python on Ubuntu using apt commands or by compiling from source. Run `sudo apt update` and `sudo apt install python` for the repository method. For the latest version, download the source code, extract it, and use `make -j 4` followed by `sudo make altinstall`.

How to install Python from Ubuntu repositories

You can install Python on Ubuntu using a simple command from the official software sources, which is the quickest and easiest way to get Python on your system.

To install Python from the Ubuntu repository, run the commands below

🐧Bash / Shell
sudo apt update
sudo apt install python

After installing Python above, run the commands below to see which versions of Python are installed.

💻Code
python --version

That should output a similar line as below with the version of Python installed. As you can see, version 2.7.18 is the current build of Python available in Ubuntu.

💻Code
Python 2.7.18

How to install Python from source code on Ubuntu

Installing Python from its source code on Ubuntu lets you get the absolute latest version and decide exactly how it’s configured, but you first need to install some essential tools that help compile the code.

Ubuntu 22.04 requires specific packages, such as `build-essential` (a collection of tools for compiling software) and `zlib1g-dev` (for handling compressed data), to compile Python from source code. You run the commands below to install these build packages before you install Python from its source code.

🐧Bash / Shell
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

After installing those packages, download the latest release’s source code from the Python download page using this `wget` command.

⚠️Warning
When writing this post, 3.9.7 is the latest Python version. If you find a later version on the site, you can download it instead.
Command Prompt
cd /tmp
wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz

After downloading the package, run the commands below, extract the file, and install it.

To begin building Python on Ubuntu Linux, use the `make` command followed by the number of CPU cores your system possesses. For example, instead of `#4`, enter your system’s core count. Using this number significantly speeds up the Python build process, making installation much faster.

For example, if your machine has 4 CPU cores, you’d use `make -j 4`.

To avoid overwriting the default system Python, it’s important to avoid the standard `make install` command. This command would replace the existing `python3` binary with your new installation.

After that, Python version 3.9 should be installed and ready to use.

To test if the latest version of Python (which is 3.9) is installed and ready to use, run the commands below

💻Code
python3.9 --version

You should see an output similar to the one below:

💻Code
Python 3.9.7

That’s how you install Python from its source

Conclusion:

This guide explains Python installation on Ubuntu Linux. Users can report errors or share additional information using the comment form provided below the article.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Install Python Pip on Ubuntu Linux
Ubuntu Linux How to Install Python Pip on Ubuntu Linux
How to Install Let's Chat on Ubuntu Linux
Ubuntu Linux How to Install Let's Chat on Ubuntu Linux
Add Multiple Clocks to Ubuntu Linux Top Bar
Ubuntu Linux Add Multiple Clocks to Ubuntu Linux Top Bar
How to Change Screen Brightness in Ubuntu Linux
Ubuntu Linux How to Change Screen Brightness in Ubuntu Linux

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *