Is it possible to upgrade Raspberry Pi to Python 3.10? Or do I have to stick with the official 3.9.2 version?
Sure, you can build Python 3.10 from source. The simplest approach is to install all the dependencies and then use pyenv, but you can do it manually too.
It’ll take a while to build Python (probably an hour or so), or you can just switch to Docker in a few minutes.
I’d say: don’t do what I did.
Python 3.10.8 is available in unstable
but it is like pulling the ball of yarn.
It will require the c compiler 12 instead of 10, then ffmpeg 7.5, then, then , then … And your system is impossible to maintain anymore.
Easiest is to limit to python 3.10, compiled from source (but you’ll need ffmpeg 7.5 from source too if you have a camera in your configuration)
I spent my whole evening yesterday removing all the unstable packages and restarted from the compiling option, following this guide using python 3.10.9.
I understand the willing to move forward with the python versions but as a majority of HA users are using a RPi and that Python 3.10 is not the official version (yet), it is a pity to force the version so early.
Or you switch in docker but it doesn’t work for me, zillions of errors in the login console and I don’t like docker at all.
I’m running Python 3.10.6 in a venv, you can check my tutorial on how to update an existing installation on: https://blog.bram.co.nl/how-to-upgrade-python-venv-to-3-8-6/
This is based on 3.8.6 but if you switch to 3.10.6 where 3.8.6 is stated it will work. Can confirm 3.10.6 is working with 2023.2. Been running 3.10.6 since it was announced deprecation.
Thanks. And yes - I learned the hard way. I just now finished reinstalling Raspberry Pi OS, Home Assistant Core, WeeWX, and my other usual apps. It definitely was not fun! Now I’m not going to mess with the built-in Python3 version anymore.
It was working with the unstable 3.10.8 of bullseye but I had a problem with 2022.2.0
It was failing to upgrade bcrypt and cryptography.
I tried to install what was missing and it was a nightmare, installing more and more unstable packages, always pushed for more. And at the end, it was rustc and stuff like that and I gave up.
I removed every unstable packages, and did python 3.10.9 using compilation of sources.
And that was enough, HA installed without any major issues.
Major why? Because when it comes to install soco (Sonos), lxml and big libraries, my RPi is stalled and never ever respond ever again. I have to monitor closely what is installing and do the following (for soco in my exemple) in a second window:
$ ps -edf | grep soco | grep -v grep | awk '{ print $2 }'
17955
$ ps --forest -o pid=,tty=,stat=,time=,cmd= -g $(ps -o sid= -p 17955)
17955 ? S 00:00:18 /srv/homeassistant/bin/python3 -m pip install --quiet soco==0.29.0 --timeout 60 --upgrade --constraint /srv/homeassistant/lib/python3.10/site-packages/ho
18030 ? S 00:00:04 \_ /srv/homeassistant/bin/python3 -u -c exec(compile(''' # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py # # - It imports s
18047 ? S 00:00:00 \_ /usr/bin/gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -I/usr/include/libxml2
18048 ? T 00:11:41 \_ /usr/lib/gcc/arm-linux-gnueabihf/10/cc1 -quiet -I /usr/include/libxml2 -I src -I src/lxml/includes -I /srv/homeassistant/include -I /usr/loca
$ sudo cpulimit --pid 18048 --limit 50 --background
Because this gcc is over 100%, all the 4 cores of the Pi are at maximum, nothing is responding and boom, deadly frozen.
Had the same on 3.10.6 with bcrypt and cryptography, but installing a later version of rust and cargo solved that, see below, this is what i posted in the Release thread of 2023.2:
In my case removing the old version and installing it again did fix the issue.
- Remove old Rustc and Cargo:
$ sudo remove rustc cargo
- Login as the HomeAssistant user and reinstall Rustc:
$ curl https://sh.rustup.rs -sSf | sh
After that logout and sign-in again as the homeassistant user and use pip to upgrade homeassistant like you normally would do.
sudo apt - get install python3.10
Lol!
Yes, 2 years later, it is available in apt
, it was not, obviously
And now HA requires 3.12, so source compilation is still a must
And now that Python 3.13.0 is out HA will shortly move to that (probably no sooner than 2024.12 or 2025.1, though quite possibly a little later).
Yes, I know, 3.13 is the latest stable on MacOS, so probably sooner than later, we will need to compile again.