How to Install Python 3.10+ on a Raspberry Pi

Richard S
2 min readDec 5, 2024

--

The Raspberry Pi’s default repositories may not include the latest Python version. To get Python 3.12.8, you can build it from source. Here’s how to do it.

Step 1: Prepare Your System

Update your system and install necessary dependencies for building Python.

sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev \
libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev wget libbz2-dev

Step 2: Download Python 3.10+ Source Code

Head over to Python’s official website to get the latest source code. Use the following command to download Python 3.12.8 directly:

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

Step 3: Extract and Navigate

Extract the downloaded archive and move into the directory:

tar -xvzf Python-3.12.8.tgz
cd Python-3.12.8

Step 4: Build and Install Python

Configure the build environment and compile Python:

./configure --enable-optimizations
make -j$(nproc) # Compiles using all available CPU cores
sudo make altinstall # Installs without overwriting the default Python

Step 5: Verify Installation

Check the installed version to confirm the installation:

python3.12 --version

You should see Python 3.12.8 as the output.

Step 6: Optional — Set as Default Python

If you want Python 3.12.8 to be the default version, update the symbolic links:

sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.12 1
sudo update-alternatives --config python

Why Build Python from Source?

Building Python ensures compatibility with the Raspberry Pi’s ARM architecture, especially when precompiled binaries or repositories aren’t available.

With this guide, your Raspberry Pi is now equipped with the latest Python! 🚀

--

--

Richard S
Richard S

No responses yet