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).

Disclaimer: This post may not be related directly to the OpenFlexure project, but it’s related to a project inspired by the OF microscopes.


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. The full story of how this project started I shared in this post.


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.



I can’t help with the Python :frowning: , but that is a cool project :slight_smile:!

1 Like

You can only venv to Python versions you actually have installed on your system. venv does not magically conjure up a Python interpreter but only sets a few search path to the right one.

The question here is not how to make Python 3.9 run on Bookworm but whether you should do that at all. Instead of trying to get Python 3.9 running I’d rather put that effort into porting your software to 3.11 if at all possible. If some libraries just can’t be ported by yourself I’d ask upstream what their plan is and then postpone the move to Bookworm until they are ready if that fits your time line.

Even if you get Python 3.9 running on Bookworm the question is where do you get that from and is it supported any longer than Bullseye.

1 Like

Hi Pierre, just in case it’s relevant, I am workingg on a rewritten version of the OpenFlexure software that works on Bookworm, with the default Python 3.11.

If you want older Python versions, sometimes you can find them in unofficial repoitories - “deadsnakes” is one I’ve used in the past with success, but I don’t know if they compile for ARM architecture.

What is it that pins you to the older Python version - is it a dependency on a particular library? If so, it’s possible that the Python version is not the only thing that will cause you problems…

Very much agreed - I have embarked on a ground-up rewrite of the OpenFlexure software for this reason - our underlying libraries (like picamera and Flask v1) were getting unsustainably old, so I’ve taken the opportunity to make some breaking changes and upgrade the stack. It’s a lot of work, but I hope it will be useful to a good number of people in the future.

1 Like

Thank you, @WilliamW @ffesti and @r.w.bowman, for your quick response and suggestions. I agree with everything you’ve mentioned. We hoped to offer users the latest OS and allow them to use the app simultaneously via a virtual environment. However, scarce resources (time and money) should be used wisely, so rewriting the code will be the way to go for the next version.

William, should I change the state of this post to “Solved”?

That is entirely up to you.