How to Install Python 3.12 on Debian 11
Python 3.12 is the newest major release of the Python programming language, and it contains many new features and optimizations.
Manually build Python 3.12 from the source code
Update System
First, ensure your system is up-to-date by running,
apt update -y
apt upgrade -y
Install Required Dependencies
Install necessary packages to build Python from source,
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 python3-openssl git
Download Python Source Code
Visit the Python downloads page to get the source code. Then, using wget
, download the source,
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
Now, Extract the Archive,
tar -xf Python-3.12.0.tgz
Configure and Build,
cd Python-3.12.0
./configure --enable-optimizations
Build Python,
make -j 8
Replace 8
with the number of CPU cores you want to allocate for the build process.
Install Python
make altinstall
Using altinstall instead of install prevents it from replacing the system's default Python interpreter (which could cause system tools to malfunction).
Verify Installation
Check if Python 3.12 has been installed successfully,
python3.12 --version
Output:
root@vps:~/Python-3.12.0# python3.12 --version
Python 3.12.0
root@vps:~/Python-3.12.0#
This should output the Python version you just installed.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS