Compiling and Installing Python 3 on Linux arm64

2026-05-20 ยท 4 min read

A complete guide to compiling and installing Python 3.12.4 on Debian 11 arm64.

The article is translated using AI.

Environment

Debian 11 arm64

Python 3.12.4

Other systems and Python versions are similar.

Prerequisites

First, update apt.

sudo apt update

Install missing dependencies.

sudo apt build-dep python3
sudo apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libgdbm-dev libnss3-dev liblzma-dev tk-dev libssl-dev libffi-dev
# May be needed
sudo apt install openssl

Installation

Download the source code from the Python official website.

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

Extract the source code and enter the directory.

tar -zxvf Python-3.12.4.tgz
cd Python-3.12.4

Generate the Makefile.

./configure \
--enable-optimizations \
--with-system-ffi \
--with-ssl \
--enable-ipv6 \
--enable-shared CFLAGS=-fPIC \
--prefix=/usr/local/python3.12.4 \
ac_cv_file__dev_ptmx=no \
ac_cv_file__dev_ptc=no

Compile.

Use the -j flag to speed up compilation, where nproc is the number of CPU cores.
make -j $(nproc)
# Or
make -j 2

Install.

# Install
make install
# Install shared libraries
cp /usr/local/python3.12.4/lib/libpython3* /usr/lib/aarch64-linux-gnu/

Post-installation

Set environment variables.

Edit the profile configuration file.

vim /etc/profile

Add the following at the end:

export PATH=/usr/local/python3.12.4/bin:$PATH

Make the environment variables take effect.

source /etc/profile

Verify the installation.

python3 --version

Uninstallation

rm -rf /usr/local/python3.12.4
rm -rf /usr/lib/aarch64-linux-gnu/libpython3*
References: https://blog.iamsjy.com/2024/07/27/compile-and-install-python-3.12.4-on-debian-11-arm64/ https://chatgpt.com/