Ubuntu 16.04 Python Upgrade, not venv

Hi All,

I would really appreciate some help how to run my homeassistant install using python 3.7. I am not currently using a virtual environment and have been happy with my system for a couple of year.

I have managed to install python 3.7:

john@dellserver:/etc/systemd/system$ python3 --version
Python 3.6.2 :: Anaconda custom (64-bit)
john@dellserver:/etc/systemd/system$ python3.7 --version
Python 3.7.5

The hass file that starts home assistant contains the following:

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from homeassistant.__main__ import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

And the home-assistant.service file contains:

[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=john
ExecStart=/usr/local/bin/hass

[Install]
WantedBy=multi-user.target

So how do I instruct home assistant to use this version when it starts.

Many thanks

Trux

Do I need to update pip to python 3.7, and adjust the top of the Hass file to /use/bin/python 3.7…

Don’t want to break everything and end up without a working system!

Many thanks

John

You could make an alias for python3 to point to python3.7

So, would I achieve this with a symlink that points python3.5 in /usr/bin to python3.7 in the same folder?

Thanks

Join

It’s currently pointing to 3.6.2 according to your first post so you just need to change that to 3.7

Thanks. I will give that a try and post if it works ok.
John

Then you should use a venv.

Should I be able to migrate all my existing entities, automationst etc… Into the venv? I know in hindsight venv would have been the right way to go, but I can’t turn back the clock. Everything is working perfectly atm. Zwave, ZigBee, etc… Im looking for the most seemless way to continue updating and not breaking anything! Also am nervous about loosing SSL access, which I configured using one of the blog guides…

It’s just a filepath. Copy your entire config directory over to the location you have set in your VENV to run HA.

Ok. This sounds like the right way to do this cleanly… I would really appreciate if you could confirm the following strps.:

Stop my existing Hass service.
Build a venv as per new install instructions
Install Hass in new venv
Copy config directory across
Create new systemd start file as per auto start guide
Disable old systemd start file
Start New Hass service
Check everything works again!

Worse case scenario if something doesn’t work or I mess up, I can start the original/ old version again. (Family now expect Hass is always available!!)

John

sounds like the right thing to do.

First step should be to have a good backup available.
Good luck!

I have a cron job that creates a back up each night, to a seperate nas drive. This bit I have done right! :slight_smile:

(I’ll need to change this or it will keep backing up the old files!!)

Reading all the guides and getting everything ready…

Do I need this step:

pip install wheel homeassistant

It is referenced in this guide: https://www.home-assistant.io/docs/installation/raspberry-pi/
but isn’t in this one: https://www.home-assistant.io/docs/installation/virtualenv/

Many thanks

John

The second is for Developers, i think the know what’s missing.
Btw, you should all python3 commands replace with python3.7
First thing i do after activating the venv, ist check the python version with only python.

python --version
(homeassistant) john@dellserver:~/homeassistant$ python --version
Python 3.7.5

The rest I will do at the weekend!

1 Like

Well, I did it. And… It worked. Yippee. Thanks for the help on this thread. Really appreciated!

John

1 Like