Bench does not work on upgrade to ubuntu 21.04

To be clear - we should never do this on a production machine. I ran the upgrade on my local machine, to see what would happen. Clearly a self-inflicted wound. I was running on the Dev branch, Ubuntu 20.04, Python 3.8.5

Upgraded to Ubuntu 21.04 (which automagically upgrades python to 3.9.5. This is something to look out for if you’re ever upgrading a Frappe/ERPnext server.

change the python version. Sometimes this does the trick.
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.9 10

go to the folder above frappe-bench. (in my case /srv/bench)
sudo -H pip3 install --upgrade --force-reinstall ./bench-repo

setup the virtual environment
cd frappe-bench (find path to virutalenv using ‘which virtualenv’)
/home/cspl/.local/bin/virtualenv -q env -p python3

install frappe
cd apps
git clone GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript --branch develop

cd /srv/bench/ (go back up)
frappe-bench/env/bin/python -m pip install -q -U -e frappe-bench/apps/frappe
cd frappe-bench
yarn install
cd apps/frappe
yarn install

install any other apps you have -
bench get-app …

bench build

now you can run bench (sudo supervisorctl restart all or bench start)

follow these instructions thereonin

Bench update --reset
bench update --patch
bench update
bench build

EDIT
For my production sandbox, the above approach did not work. This was a bit more challenging.

I renamed my original frappe-bench folder.
ran the bench init command
bench init frappe-bench --frappe-path GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript --frappe-branch develop --python python3

copied over the frappe-bench-archive/site/TENANTs folders to frappe-bench/site/*

Next: setup nginx
bench setup nginx
sudo rm -f /etc/nginx/sites-enabled/*
sudo ln -s /srv/bench/frappe-bench/config/nginx.conf /etc/nginx/sites-enabled/frappe.conf

Setup the firewalls (probably as a result of the upgrade, firewalls were not working)

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw enable
sudo ufw app list
sudo ufw allow ‘Nginx HTTPS’
sudo ufw allow 22,25,143,80,443,3306,8000/tcp