Jun 4, 2024 4 min read

How to Install Python 3.12 on Ubuntu 20.04

Install Python 3.12 on Ubuntu 20.04 with our step-by-step tutorial. Python is a known high-level language appreciated for its readability.

Install Python 3.12 on Ubuntu 20.04
Install Python 3.12 on Ubuntu 20.04
Table of Contents

Choose a different version or distribution


Before we begin talking about how to install Python 3.12 on Ubuntu 20.04, let's briefly understand – What is Python?

Python is a popular high-level programming language known for its versatility and readability. It is beginner-friendly and widely used for web development, data analysis, artificial intelligence, and more. Python's clean syntax makes it easy to learn and use, even for those new to coding.

With a vast collection of libraries and frameworks, Python empowers developers to build diverse applications efficiently. Embraced by programmers worldwide, Python continues to shine as a go-to choice for various software projects.

In this tutorial, you will install Python 3.12 on Ubuntu 20.04. We will also address a few FAQs on how to install Python 3.12 on Ubuntu 20.04.

Advantages of Python 3.12

  1. Type Parameter Syntax: Type parameter syntax and type statement introduced for more concise and explicit creation of generic classes and functions.
  2. Enhanced F-Strings: F-strings now support backslashes, unicode characters, multiline expressions, and comments, removing previous limitations and improving error messages.
  3. Performance Boosts: Asyncio package performance improved for those relying on asynchronous programming.
  4. Typing Module Enhancements: New syntax for generic types and aliases promotes clearer code with static type checkers.
  5. Security Improvements: Formal verification for built-in implementations of SHA and MD5 hash functions through the HACL* project, improving security and reliability.

Manually build Python 3.12 from the source code

Update System

Firstly, make sure your system is updated by executing,

apt update -y

apt upgrade -y

Install Required Dependencies

Install the required packages in order to build Python from scratch.

apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
    libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
    xz-utils tk-dev libffi-dev liblzma-dev python-openssl git

Download Python Source Code

To obtain the source code, go to the Python downloads page. Next, download the source using wget.

wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz

Extract the Archive now:

tar -xf Python-3.12.0.tgz

Configure and Build:

cd Python-3.12.0
./configure --enable-optimizations

Build Python:

make -j 8

The number of CPU cores you wish to set aside for the build process should be substituted for 8.

Install Python

make altinstall

It won't replace the system's default Python interpreter if altinstall is used instead of install, which could lead to system tool malfunctions.

Verify Installation

Verify that Python 3.12 has been installed properly.

python3.12 --version


The Python version that you just installed should appear.

Install Python 3.12 from the deadsnakes PPA

Install the prerequisite so that custom PPAs can be added.

apt install software-properties-common -y

Add deadsnakes PPA,

add-apt-repository ppa:deadsnakes/ppa

Add packages from the recently added PPA to the package lists.

apt update -y

Install Python 3.12

Now, you can use the apt package manager to install Python 3.12.

apt install python3.12

Verify Installation,

python3.12 --version


Python 3.12 will not automatically install the PIP after it is installed using the APT package manager. To install PIP, execute the subsequent command:

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12

Now use the command below to verify the PIP version.

pip3.12 -V


That concludes our discussion! Now, you can create web apps, build software, set up workflows, and more with Python 3.12.

FAQs to Install Python 3.12 on Ubuntu 20.04

What are the system requirements for installing Python 3.12 on Ubuntu 20.04?

Python 3.12 requires Ubuntu 20.04 or later, with a minimum of 2 GB RAM and 10 GB disk space.

Can I use Python 3.12 for web development on Ubuntu 20.04?

Yes, Python 3.12 can be used for web development on Ubuntu 20.04. You can use frameworks like Django and Flask to build web applications.

Are there any known issues with installing Python 3.12 on Ubuntu 20.04?

There are no known major issues with installing Python 3.12 on Ubuntu 20.04. However, you may encounter minor issues or conflicts with other packages.

Can I upgrade from an earlier version of Python on Ubuntu 20.04?

Yes, you can upgrade from an earlier version of Python on Ubuntu 20.04. The sudo apt-get install python3.12 command will automatically upgrade your existing Python installation.

How do I set up a Python 3.12 environment on Ubuntu 20.04 for a specific project?

To set up a Python 3.12 environment for a specific project on Ubuntu 20.04, you can use a virtual environment tool like virtualenv or conda. This allows you to isolate your project's dependencies and avoid conflicts with other projects.

Are additional packages or libraries required after installing Python 3.12 on Ubuntu 20.04?

Essential packages come with the default Python installation on Ubuntu. However, for specific projects or tasks, you may need to install particular libraries using pip, Python's package manager, to meet your project requirements.

How can I run Python from any directory on Ubuntu 20.04?

To run Python from any directory on Ubuntu, you can add the path to your Python installation directory to the PATH environment variable. This allows you to execute Python commands from any location in the terminal.


We hope this tutorial helped you understand how to install Python 3.12 on Ubuntu 20.04.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.