0% found this document useful (0 votes)
195 views15 pages

How To Install Python 3.12.3 On The Raspberry Pi

B

Uploaded by

faszomjoska23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
195 views15 pages

How To Install Python 3.12.3 On The Raspberry Pi

B

Uploaded by

faszomjoska23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

3/28/25, 9:53 PM How to Install Python 3.12.

3 on the Raspberry Pi

arul's blog Home Blog Bible Code


MAC Address lookup IP Address lookup
Phone lookup
H
R
H

T
B
p
th

P
m
y

W
https://aruljohn.com/blog/python-raspberrypi/ 1/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

I use Python for various purposes all my Raspberry Pi boards. I run automated
scripts, web applications that help in home automation, web controllable
Christmas lights and more recently AI/machine learning.

Download Python 3.12.3 source


First, setup Raspberry Pi OS on your microSD card. You can read my previous
blog post on how to do it.

Run this command to download the latest Python source code.

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

$ wget https://www.python.org/ftp/python/3.12.3/Python-3.12.3.tgz
--2024-05-21 14:23:57-- https://www.python.org/ftp/python/3.12.3/Python
Resolving www.python.org (www.python.org)... 151.101.40.223, 2a04:4e42:7
Connecting to www.python.org (www.python.org)|151.101.40.223|:443... con
HTTP request sent, awaiting response... 200 OK
Length: 27159482 (26M) [application/octet-stream]
Saving to: ‘Python-3.12.3.tgz’

Python-3.12.3.tgz 100%[=====================================>]

2024-05-21 17:24:02 (6.02 MB/s) - ‘Python-3.12.3.tgz’ saved [27159482/27

 

Install the build tools


Run these to install the build tools.

libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi

 

If you want, you can install git as well.

https://aruljohn.com/blog/python-raspberrypi/ 2/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

sudo apt install git

Configure, make and make install


Untar the .tgz file and change to the Python source directory.

tar -xzvf Python-3.12.3.tgz


cd Python-3.12.3/

Next, we run configure and make. The configure command may take several
minutes depending on your Raspberry Pi. On my Raspberry Pi v3, this took about
45 minutes.

./configure --enable-optimizations
sudo make altinstall

If you want it to build faster, you can replace ./configure --enable-


optimizations with ./configure. In that case, you will be doing this.

./configure
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

You will get this output:

Python 3.12.2

Make Python 3.12 the default version

https://aruljohn.com/blog/python-raspberrypi/ 3/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

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

/usr/bin/python3 -V
Python 3.11.2

To make the default version of Python 3.12.3, create a softlink. Run this:

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

If that does not work, repeat the process for python3 instead of python.

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

You can also create a softlink /usr/local/bin/python.

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

Test Python version


Test whether Python 3.12.3 is the default version:

python -VV
Python 3.12.3

If you want to know which version of Python has precedence, you can use the
which command.

This is the command on my Raspberry Pi 3.

$ which python
/usr/local/bin/python

https://aruljohn.com/blog/python-raspberrypi/ 4/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

$ which python3
/usr/local/bin/python3

You can also check your Python versions using the whereis command.

$ whereis python
python: /usr/bin/python /usr/share/man/man1/python.1.gz

$ whereis python3
python3: /usr/bin/python3 /usr/lib/python3 /etc/python3 /usr/local/bin/p

 

Delete the installation directory


At this point, you can safely delete the installation directory.

cd /tmp/
rm -rf rm -rf Python-3.12.3.tgz Python-3.12.3/

How to upgrade from Python 3.12.x to 3.12.3


The process is exactly the same, except that Python 3.12.3 will automatically
become the default after you complete installation. You may not have to change
the softlinks.

Conclusion
Let me know whether you have any problems installing Python 3.12.3 in your
Raspberry Pi.

This blog post will be regularly updated, usually once in two months.

RASPBERRY PI PYTHON MACHINE LEARNING AI

Related Posts

https://aruljohn.com/blog/python-raspberrypi/ 5/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

👉 How to install Raspberry Pi OS bullseye on a Raspberry Pi Zero or Zero 2


W using rpi-imager

👉 How to Find the Temperature of a Raspberry Pi


👉 How to Install Raspberry Pi OS Bookworm Using dd on the Command
Line

👉 How to Convert Your Wired Printer to Wireless Using Raspberry Pi


👉 How to sync your Raspberry Pi to remote time servers
👉 Web Controllable Christmas Lights using Raspberry Pi and RGB LED
Strip

👉 How to Install git 2.32 on Raspberry Pi


👉 Bash script to reconnect Wi-Fi connection in Raspberry Pi
👉 Python for Kids: a 30-Day Roadmap
👉 ACSL Junior Duplicates Problem
If you have any questions, please contact me at [email protected]. You
can also post questions in our Facebook group . Thank you.

https://aruljohn.com/blog/python-raspberrypi/ 6/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

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: July 02, 2024. This post was originally written on August 10, 2021.

← Previous Post Next Post →


Comprehensive List of 50 Job Interview How to encrypt and decrypt text files using
Questions Vim editor

Comments
Leave a Message

Your email address will not be published. All fields are required.

Add your comment

Enter your full name

Enter your email address

Add your Comment

Jashiel wrote on 2025-03-24 03:43:28


Thanks. It works :) 


 

Arul John wrote on 2024-12-29 14:12:23


Hello Mike, thanks for the comment! I will add the bz2 and lzma 
module installation steps to the blog post.

 

Mike Stupak wrote on 2024-12-27 02:47:22


Running on a 4b. This was a great start. I had to add the following 
modules to the build to get my stuff working:

https://aruljohn.com/blog/python-raspberrypi/ 7/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

sudo apt-get install libbz2-dev 


sudo apt-get install liblzma-dev

Arul John wrote on 2024-12-23 20:43:45


Hi Rhiz3K, thanks for the comment! I will add it to the blog post. 

 

 

Rhiz3K wrote on 2024-12-21 07:14:54


For problems with pip: 
python3 -m ensurepip --upgrade
pip install --upgrade pip 
 

Arul John wrote on 2024-06-20 06:02:01


Hi ola ,thanks for your comment! I did not try it with a Raspberry Pi 
B+ recently, but it did work in the past. It will take several hours
though. I use them with Raspberry Pi 3 model B and 4 model B. 
 

ola wrote on 2024-06-18 21:53:06


Hello, has anybody tried it with a Pi B+? Yes, I know it's very old, 
but that's the one I got :D I get the following message when
configure is done: "Platform "armv6l-unknown-linux-gnueabihf" with
compiler "gcc" is not supported by the
CPython core team, see https://peps.python.org/pep-0011/ for more
information."
So I assume the tutorial is not working because there is no gcc
available for such an old device? Quite new to programming on Pi's :)

Thank you for this post, even if it doesn't work yet for me I learned
a lot :) 
 

Arul John wrote on 2024-05-21 12:35:11


Hello Peter, thanks for your comment! Please run these commands. I 
will update my blog post.

sudo rm /usr/local/bin/python
sudo ln -s /usr/local/bin/python3.12 /usr/local/bin/python 
 

Peter Stemann wrote on 2024-05-21 12:29:29


Hello and thank you very much for this great instruction. 
I intended to update from 3.11.4 to 3.12.3 and followed you advise,
adopting the details. Unfortunately, the default is still 3.11.4:
ste@RPi024:~/Python-3.12.3 $ /usr/bin/python -V
Python 3.12.3
ste@RPi024:~/Python-3.12.3 $ python -VV

https://aruljohn.com/blog/python-raspberrypi/ 8/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

Python 3.11.4 (main, Jun 30 2023, 18:18:45) [GCC 10.2.1 20210110] 

Any idea on how to proceed?


Thanks in advance
Peter

Arul John wrote on 2024-04-01 16:52:08


Hi Stephen, thanks for the update. Glad you got Python to work. I 
will include updating the Raspberry Pi image in this blog post.

 

Stephen wrote on 2024-04-01 12:40:05


In order to install an A to D I needed PIP3 which needed Python3 
which needed C update so I got the latest Raspberry pi image and got
it all in one go 
 

Arul John wrote on 2024-03-15 16:49:22


Hello Stephen, it appears that your version of C (cc1) is very old. 
Can you please update it and try building Python again? You can also
email me directly. Thanks. 
 

Stephen Fincham wrote on 2024-03-15 15:54:42


ccl:error:unreconized command line option '-std=cll' 
makefile:14481: recipe for target 'Programs/python.o'failed
make: *** [Programs/python.o] Error1 1 
 

Stephen Fincham wrote on 2024-03-15 15:30:45


All appeared to work ok until the last command sudo make altinstall 
when I got error recipe for target 'Programs/python.o' failed any
help would be appreciated 
 

Arul John wrote on 2024-03-14 06:19:34


Hi Nicholas, thank you for your comment! 


 

Nicolas Vaagen wrote on 2024-03-14 01:45:10


Thank you for posting this. I was having trouble with guides that did 
not share the dependencies.

Much appreciated 
 

https://aruljohn.com/blog/python-raspberrypi/ 9/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

Arul John wrote on 2024-03-12 19:51:16


Hi fableman! pip will not break, but if there are multiple versions 
of Python and if the right pip or pip3 is not set in the path, you
can install it in the other version than the one you intended.
python -m pip is a good practice, though, especially when for
Windows. I am adding it to this blog post. Thanks! 
 

fableman wrote on 2024-03-10 18:54:22


pip will get broken 
need to use python -m pip

 

Arul John wrote on 2024-03-06 15:17:44


Hi Armin, thank you for your comment! I will test new Python 3.12.2 
installations on my 3B and 4B and update the blog post accordingly.

 

Armin Jago wrote on 2024-03-06 13:31:31


Hi Arul, 
I am retired and train my brain with raspberry PI 4. Your AP works
well, but took 1h.
Thanks
armin

 

Arul John wrote on 2024-03-05 04:56:30


Oops, thanks, John Doe! Corrected it. :) 


 

John Doe wrote on 2024-03-03 16:58:26


"How to upgrade from Python 3.12.0 to 3.12.0" reads the same version. 
Surely you mean "from 3.12.0 to 3.12.2" ?

 

Arul John wrote on 2024-01-26 17:34:23


You're welcome, M R L RAO. Thanks for reading. 


 

M R L RAO wrote on 2024-01-22 07:28:22


Thank you 


https://aruljohn.com/blog/python-raspberrypi/ 10/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi


Arul John wrote on 2024-01-04
 
Thank you, Harmen. I updated the blog post. 


 

harmen van der stouw wrote on 2024-01-03 23:29:21


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

this wil not work.

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

this wil work 


 

Arul John wrote on 2024-01-01


Hi Geoff, it can take about an hour for my Raspberry Pi 3 and 4B. 


 

Geoff Meston wrote on 2023-12-31 16:10:40


the 'sudo make altinstall' is taking an age, like 40mins so far? 
How long should this take?
New Rasberry Pi 4b with 4gig ram, 32gig micro SD card running full
Raspberry OS 
 

Shane Platt wrote on 2021-12-23 10:22:00


I followed the instructions, including the last step where i 
confirmed my python version. However, if i type python3 and hit enter
in the terminal, python 3.73 is loaded, when I try to install a
python package it doesn't install to the 3.96 version, it installs in
3.73. I can set Visual Studio Code interpreter to the 3.96 version,
but I cant import any modules due to the pip installation installing
to 3.73 and not 3.96. Any advice on how to install modules to 3.96
and not 3.73?

Thanks,

Shane 
 

Arul wrote on 2021-10-19 10:06:00

https://aruljohn.com/blog/python-raspberrypi/ 11/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

Supra, yes, you can. Just make sure that your OS doesn't have any 
dependencies on 3.7.3. I prefer to leave the older versions alone if
they come with the default OS. 
 

Supra wrote on 2021-10-19 09:56:00


Can I remove 3.7.3 and replace a newer version 3.9.6? 


 

LeeG. wrote on 2021-09-30 19:16:00


Thanks. Works perfect with 3.9.7 on Pi 4B 


 

Michael Boulton wrote on 2021-09-15 07:52:00


Thanks Arul. It worked perfectly. 


 

Search blog posts

Categories
-select category-

Recent Articles

Learning to Build AI Agents: a Roadmap

Python for Kids: a 30-Day Roadmap

Casio G-Shock GWM5610 Watch Review

How to Format a MicroSD or SD Card


Using dd

How to Format USB Flash Drive Using dd

Cryptocurrency SMS Text Message


Scams

https://aruljohn.com/blog/python-raspberrypi/ 12/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

RubyConf 2013

Popular Articles
How to find IP address of email sender

How to install Python 3.12 on Debian

What to pack when visiting the Philippines


🇵🇭

Common scams targeting senior citizens

How to set up a natural shrimp aquarium

Control your Christmas RGB lights from


your website using a Raspberry Pi

Comments
✏ Blog Comments

Our books

ACSL Elementary Division Study Guide

Number Systems Practice Exercises

For the Spirit that God has given


us does not make us timid;
instead, His Spirit fills us with
power, love, and self-control.
~ 2 Timothy 1:7

https://aruljohn.com/blog/python-raspberrypi/ 13/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

About Network Utilities Text/Math Utilitie


My name is Arul and I work as a 🛠 MAC address lookup 🎼 Get YouTube thu
software engineer at NASA. This 🔧 IP address lookup 🗝 MD5 Hash gener
website consists of a collection of 📨 Find IP address from email 🔀 JSON Sort
tools, utilities and articles I wrote ❌ IP address Blacklist checker 🔠 Text Case
over the last 24 years. The Blog 🔢 IP address to Decimal 🐠 Aquarium calcul
section covers several articles from 🔒 SSL Certificate Expiration Date 📅 Timestamp to Da
technical to aquarium topics. You 📞 Phone number lookup 🎨 ASCII art genera
will also find free APIs that you can 🖥 IP to Hostname Miscellaneous
use in your applications. 🖥 Hostname to IP ⛽ Costco gas price
Connect 🖥 IP/CIDR subnet ⛽ Costco gas price
Subscribe to RSS feed 💻 View HTTP headers ⛽ Costco gas price
Follow on Facebook 💻 Which Webserver 👶 Baby Names ran
Discuss on Facebook group 🛠 MAC address generator 🗣 Word pronunciati
My GitHub profile 🛠 IP address generator 👾 User-Agent data
🗝 Wireless Network Key 🎭 Gravatar icons
Geographic 🕸 Detect Browser L
🇺 US States/territories 🦹 Proxy Server ch
💳 SSN lookup 🤐 Gzip Compressi
🔧 Zip code lookup 🤐 Latest Deals on
📌 Areacode lookup Costco Gas Pric
📌 Country lookup ⛽ California, Hawa
Pennsylvania, Wash

Copyright © 2000 - 2025 Arul John

https://aruljohn.com/blog/python-raspberrypi/ 14/15
3/28/25, 9:53 PM How to Install Python 3.12.3 on the Raspberry Pi

home about me contact me articles & blog code Bible Costco gas prices APIs

Update Privacy Settings

https://aruljohn.com/blog/python-raspberrypi/ 15/15

You might also like