Python upgrade

Great!
For increased instability we now use a problem-prone application on a buggy OS and need to determine which part is causing a particular issue.

People use Hassbian because, like Hassio HassOS, it is a complete image for those who have advanced a little beyond the beginner stage & want more flexibility/customization. Yes, the real techies can “roll their own” but many of us do too much of that for our job and want things that work fairly reliably.

For now I am stepping back & considering my options.

1 Like

+1 here too.

The last couple of updates have been so time consuming my HA server has had more downtime than uptime trying to resolve the issues.

My current install 0.93.2 appears to be quite stable at the moment so until I can work out a definitive way of progressing beyond it and the Python issue I’m afraid I’ll be like Moses as far as the the great Home Assistant v 1.0 project is concerned. I made the journey but I won’t get to see it :sob:

1 Like

We need to find Joshua :smiley:

Or even The Holy Grail that is HA v1.0. Now that will be interesting to witness :laughing:

1 Like

I feel like Caleb, the old man along for the ride :wink:

1 Like

I am running Raspbian Stretch Lite with Python 3.5.3, with HA in a venv. As you I am searching a reliable way to update to Python 3.7.3. It seems that it can be done with code from this link. I still haven’t done, maybe this weekend. I want to do a SD backup first, in case something go wrong.

I guess I need a bit more help. I am still running on my original All In One Installer. When I upgrade HA I use the commands
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/homeassistant_venv/bin/activate
pip3 install --upgrade homeassistant
I followed the procedure at my normal login but my HA is still showing python version 3.5.3. I tried to do the procedure within
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/homeassistant_venv/bin/activate
but when I get to sudo make install I get a prompt asking for homeassistant password. I have tried every password I have ever used on the pi and HA and nothing works. Any help would be appreciated. Thanks

Of course it will. All you’re doing is updating Hass and not the Python end it is installed in.

As I mentioned so many looking for guidance on this subject.

I will attempt to pull all the suggestions that were made together and see if I can come up with a simple copy/paste set of instructions to achieve this.

Any Hass venv users please feel free to pitch in on this. This is something all venv users can use going forward.

I can throw out some untested ideas.

  1. Upgrade python on your OS.
  2. In your venv run pip freeze > requirements.txt This creates a file with the installed python modules.
  3. Stop Home Assistant
  4. Delete the old venv (need to verify how)
  5. Create a new venv In /srv/homeassistant, run
$ sudo -u homeassistant -H -s
$ cd /srv/homeassistant
$ python3 -m venv .
$ source bin/activate
  1. Install the modules pip install -r requirements.txt
  2. Start Home Assistant
  3. ?? Profit ??

That’s definitely taking shape along the lines I was thinking.

From what I was reading you can have as many different versions of Python on your system as long as they are isolated in separate folders from each other.

So as I’m reading it you need to do the following

  1. Download the Python source of your choice into your chosen folder

  2. Build the binaries

  3. Install those binaries

  4. Create the venv

  5. Restore your HA config to the new venv

Have I missed anything here.

Well technically your HA config lives outside of the venv in /home/homeassistant/.homeassistant/, your venv of python lives in another directory ie: /srv/homeassistant/

No need to restore anything as the config doesn’t go anywhere.

1 Like

Your steps 1 - 3 are my step 1. :wink:

You forgot my steps 2 - 4, Your Step 4 is my step 5. You do not need to touch your configuration since it is elsewhere.

You DO need to install the python modules in the new venv and restart Home assistant, though.

1 Like

So it is referenced through symlinks or such like

Nope, no symlinks at all the hass python code takes a -c parameter for the location of your config files.

1 Like

I’m so looking forward to seeing the finished product. My anorak is tightening with every post :joy:

Oh-oh! Bad news.
People usually install a venv it own subdirectory.
If you follow the official manual installation instructions, the venv files are mixed in with the homeassistant ones. That means, to be safe, tou need to delete Home Assistant & reinstall too.

Here are those instructions.

But does anyone know if just installing HA via a new Hassbian image includes the latest Python version?

I would think that should be the easiest way of upgrading if you don’t have much installed and running on your Pi besides HA.

I saw somewhere that the new Hassbian image is based on the unstable Debian Buster. There is a Hassbian script to upgrade python that would be safer if you are already running Hassbian.

sudo hassbian-config upgrade python

Absolutely agree with you there.

It kind of sucks that this was thrown on users so suddenly tho.

If you installed HA venv in the standard location (/srv/homeassistant) and if you don’t have any other sub-directories in your /srv directory then you can remove it using this:

$ cd /srv/
$ sudo rm -r *

otherwise just find out where your venv directory is and delete that individual directory.

What modules need to be installed directly into the venv?

Once you delete the old venv, create a new one and then install HA in the venv I don’t think there is anything else to install in the venv. You should pretty much never have to enter the venv to do anything except to update HA.

true, but if you aren’t already running Hassbian it might just be easier to install it which would include all of the updated stuff. then just copy your config back to the SD card and be done with it.