Upgrade on pi4 hassio in a python virtual environment

Hi,hopefully a quick yes or no answer. I want to upgrade my pi4 from 0.115.6 to 2021.1 or current version, Ive upgraded previously with no issues!!. But I see that for 2020/2021 that I need to be using python 3.8, my question really is how do I upgrade the python virtual env prior to upgrading HA without losing my current config? Is it just a case of backing up ~homeassistant/.homassistant, sudo apt-get install update etc … in the virtual env or do I have to re-create a new python virtual env? and if so will my config still be valid when I put it back?

Any help greatly appreciated, before I take the plunge!!!

I upgraded my Python version on an RPi 3b+ to 3.9 in November (I think). My RPi runs Buster so I had to download and install manually as Python 3.9 isn’t yet available via apt. You’ll be installing 3.8 so you shouldn’t have this extra step. One benefit of this is that the original Python included with the distro remains untouched.

Your config typically sits in some .homeassistant directory and your venv will be in /srv/homeassistant/ if you followed the standard guide.

When you upgrade Python, it will only affect the venv and not your config but for safety, I’d always make a backup. You need to recreate the venv.

Some useful guides:

I might be wrong, but for me it doesn’t sound like you are really familiar with Python and virtual environments.
Is there a specific reason to use HA in a virtual environment? I’d suggest switching to one of the other installation methods and save you some headache in the future, because in a year you’ll be doing the same thing and a year later again etc.
See here an excellent overview of the differwnt installation methods:

Thanks parautenbach that is what I suspected. I didn’t find these docs amongst the “several” I read, Ill have another read. Thanks again.

Hi Burningstone, I started using HA a couple of years back, and using a virtual env was the recommended way to install if you wanted to use the pi for other things at the same time. So, I have stuck with it.

Thanks

Hi parautenbach, sorry meant to ask, why did you install 3.9?

Then do the switch now :slight_smile:

1 Like

:+1: Go for HA Core on Docker

1 Like

Yes I did read that already, which do you use ?

I jumped to 3.9 as the latest stable release on python.org basically because I read in the HA release notes that HA’s support for 3.7 will stop with the next release (at the time) and I didn’t want to upgrade twice in short succession. I was happy to be a guinea pig to see if I get any issues with HA on 3.9 (I don’t think it was tested officially at the time). The Python release notes didn’t flag anything for me either (given my scope). I haven’t had any issues but if I did I would’ve installed the latest 3.8 version.

I’d like to echo what Burningstone has said: If there’s not a specific reason for running HA core in a venv rather pick a different installation method. There are some good but esoteric cases for running in a venv (personally I’m ok dealing with the Python upgrade) and I like to experiment a bit with some things.

1 Like

Home Assistant Container in production, Home Assistant Supervised in a test environment and Home Assistant Core in another test environment.

It all depends on your needs and skills

Soooo, Ive spent all weekend trying to update to 2021.1.3. I first tried hassos/hassbian, i had the card build ready to start but then read an article on here that stated that hassos/hassbian was going to be retired so I stopped with that. I then tried Docker but this came up with error after error during installation, I could fix them 1 by 1 but I gave up on that too as it was taking so long.

So in the end I stayed with a python virtual env, I backed everything up, recreated a new python environment, based on Python 3.9.1. (taking into account possible future upgrades). The whole installation went without a hitch, everything works! Even my big worry about MariaDB in an external SSD, but this simply updated its schemas when I ran hass and its all perfect!! It also means that everything else I have running in the normal OS is still OK. An added bonus is that I ended up with 2021.1.4!

Any way thanks for all your advice, it made think about what I wanted to do.

1 Like

Hassbian has been retired long time ago, HassOS definitely not! Where did you read that?

My mistake, I was grouping both together as the same thing!!! Just as well I didn’t try to install it as I only have a Pi Zero spare at the moment.