Download Python 3.12.0 source

First, setup Raspberry Pi OS on your microSD card.

Run this command to download the latest Python source code.

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

Install the build tools

Run these to install the build tools.

sudo apt update

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev

If you want, you can install git as well.

sudo apt install git

Configure, make and make install

Run these commands. The configure command may take several minutes depending on the Raspberry Pi.

tar -xzvf Python-3.12.0.tgz

cd Python-3.12.0/

./configure –enable-optimizations

sudo make altinstall

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

/usr/local/bin/python3.12 -V

It will get this output:

Python 3.12.0

Make Python 3.12 the default version

When run python, you will still get the default 3.9.2.

/usr/bin/python3 -V

Python 3.9.2

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

sudo rm /usr/bin/python

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

Test whether Python 3.12.0 is the default version:

python -VV

Python 3.12.0

 

By Rayhan

My name is Rayhan and I'm an IT professional with over 10 years of experience in the field. I'm passionate about all things tech, and I love helping people solve their IT problems. In my free time, I enjoy tinkering with new gadgets and software, and I'm always on the lookout for the latest tech trends. I believe that technology has the power to make our lives easier and more enjoyable, and I'm excited to be a part of this ever-evolving field. Thank you for taking the time to visit my page.

Leave a Reply

Your email address will not be published. Required fields are marked *