To install 3.9:
Python 3.9 is not available by default in Ubuntu repos so:
#Add repo
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
#Check 3.9 available
sudo apt list | grep python3.9
#Install 3.9
sudo apt-get install python3.9
#Add 3.9 to the versions of Python available. Ubuntu will try to use 3.6/7 by default
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
#Now configure system to use 3.9 as default.
sudo update-alternatives --config python3
Choose 2
To confirm 3.9 being used:
python3 -V
Here are the steps I used for the upgrade to 3.7 many moons ago. Not tried it yet and will try to update to 3.9 later next week, but feel free to give it a go. I have amended it for 3.9
systemctl stop [email protected]
apt update
apt install python3.9
apt install python3.9-dev
apt install python3.9-venv
cd /srv
mv homeassistant homeassistant_old
mkdir homeassistant
chown homeassistant:homeassistant homeassistant
sudo -u homeassistant -H -s
cd /srv/homeassistant
python3.9 -m venv .
source bin/activate
pip install --upgrade pip
python3.9 -m pip install mysqlclient
python3.9 -m pip install homeassistant
pip install home-assistant-frontend
exit
systemctl start [email protected]
journalctl -f -u [email protected]
Running in Ubuntu 18.04 LTS and I use an external MySQL database.
As I say none of this is tested yet, but I can’t see why it won’t work.
Cheers
mb
EDIT: just saw you are using RPI OS - this should work on that too - I will check on one of my PIs later.
EDIT2: Just ran all the above against my Ubuntu Core install and all is good. The only issue I had was that in my service file I had pointed to a different path (when I upgraded from python3.6 → 3.7) rather than /srv/homeassistant - once I corrected that all was good in the hood 