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