How to install Python 3.12.2 from source

Published February 08, 2024

Installing Python 3.12.2 on Debian

The latest version of Python is 3.12.2 and was released on February 6, 2024. This version is the second maintenance release, with more than 350 bugfixes since 3.12.1.

Here are steps to install Python from source. This tutorial will work for Debian, Ubuntu and their derivatives, Red Hat, Fedora and most Linux operating systems.

Download Python 3.12.2 source

The latest Python source code is available here.

First, download and extract the latest Python source code.

cd /tmp/
tar -xzvf Python-3.12.2.tgz
cd Python-3.12.2/

Install the build tools

Now, install the build tools. The build tools includes gcc, make, zlib, ssl libraries and other libraries.

On Debian or Ubuntu:

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev

On Red Hat or Fedora:

sudo dnf update
sudo dnf groupinstall "Development Tools" "Development Libraries"

Configure, make and make install

./configure --enable-optimizations

Before running make, find the number of processors your server has using nproc.


You will see something like this:


Now, run make with the number of processors. This may take a while.

make -j 2

You can also run make and use the nproc output in one step:

make -j `nproc`

Make install

We will install Python under /usr/local/bin instead of overwriting the default Python installation under /usr/bin.

sudo make altinstall

This will install Python at /usr/local/bin/python3.12. To test the version, run this:

python3.12 -V

You will get this output:

Python 3.12.2

Make Python 3.12.2 the default version

To make the default version of Python 3.12.2, run this:

$ sudo ln -s /usr/local/bin/python3.12 /usr/local/bin/python

Test whether Python 3.12.2 is the default version:

$ ls -al /usr/local/bin/python
lrwxrwxrwx 1 root root 25 Dec 26 13:08 /usr/local/bin/python -> /usr/local/bin/python3.12
python -VV

The output will be:

Python 3.12.2 (main, Feb  8 2024, 13:06:49) [GCC 10.2.1 20210110]

If you liked this post, please feel free to share it. If you have any problems installing Python 3.12.2 from source, you may contact me.

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Last Updated: February 08, 2024. ย ย ย  This post was originally written on June 25, 2022.