Help to downgrade Python version in Bookworm (Raspberry Pi OS)

Hi everyone :raising_hand_man:t4: I would like to request some help to downgrade the Python version in Bookworm (the latest version of Raspberry Pi OS).


Currently, I am working on a strobe-enhanced microscopy stage for droplet microfluidic assays. The Raspberry Pi boards are used as the brain of our stage. We already have a functional version that has been used in some microfluidics workshops and lectures.


In October, a new Raspberry Pi OS called Bookworm was released and it comes with Python3.11. We would like to release a custom image with our software based on this OS. Unfortunately, our UI is only compatible with Python3.9. For this reason, I tried to downgrade Python but without success. I tried to create virtual environments (venv) with the required Python version but RPi didn’t allow me to do it. Only venv with the same Python version (3.11) could be created. By this time, I haven’t found any tutorial based on Bookworm.

Is there someone who has tried to downgrade the Python version? Do you know or have any tutorial to do it safely?

PS. Everything works well with Bullseye.



1 Like

Hi, I haven’t been in exactly this situation but in the past I’ve had good luck with the following tools

  • deadsnakes PPA
  • pyenv environment management tool

Good luck


Hi Pierre!

Downgrading the python version is not easy as all the python libraries provided also depend on the 3.11 version, and probably some core RPiOs libraries tools.

You can install another python version “alongside” the default one, one way is to build and install it from source (here are the source downloads ) And here some generic instructions

The issue with this solution is that usually you not only need Python but also other libraries for that version. So, not an easy real solution in practice (you can build all the libraries you need for that Python version but depending on your use case it can be a lot of work)

I would recommend you to try to port it to Python 3.11 and if you can’t do it, to use a Docker image for the RPi that is based on bullseye.



Thank you, @blaise and @spiccinini, for your quick response and suggestions. I got similar recommendations on the OpenFlexure Forum. I appreciate OSH community support :pray:t4:

NOTE: Consider advice from this post if you are a newbie developing open-source hardware that includes Python packages. They will save you time and money.

@biomakers_lab Anaconda is a fairly heavy environment resource-wise, but I use it all the time on my laptop to create various environments with different versions of Python. I have not tried it on an RPi though.


Installer for ARM64:

There are also variants like mamba that are lighter on resources and faster, but I don’t know how well they will work on the RPI either. Some instructions for an open source project I contribute to can be found here for installing a variant of Anaconda without breaking your local Python environment. You might have to modify the curl line in the command listing if the download package is not found. There is definitely an ARM64 package though: downloads link.

I use the conda command to set up an environment with a specific version of Python (conda create -n myenv python=3.9), and then use pip to install Python packages. Mixing the two packaging systems this way does not always make the Anaconda devs happy, but it works well for me and others.

1 Like

One thing I have been using on a daily basis, and quite similar to venv is this virtualenvwrapper — virtualenvwrapper documentation maybe gives you better luck in creating environments with different python versions.

On that note, this might also be useful figuring out differences between env packages: What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv?

and if you do end trying to use virtualenvwrapper, here is a small tutorial Python virtual environment | The Raspberry Pi Guide

1 Like