I have an install from home assistant that I did last January on an Ubuntu virtual machine running on my esxi server. I did an install in a python virtual environment as documented in the advance guide.
I recently tried to upgrade my install, but ran into a bunch of issues. Firstly my python was too old, so I upgraded that, then I did a pip3 install --upgrade homeassistant but that caused home assistant to stop working.
Lukily I had a backup of the VM and restored that, but right now I’m stuck at the upgrade.
I’m happy to wipe and start again but would prefer not to as I also have dasher etc working on the same virtual machine- any advice on upgrading?
If you upgraded python, your virtual environment is probably still referring to the old version of python. The whole purpose of virtual environments is to define versions of these things so that the environment doesn’t change underneath the python program.
The simplest thing to do is to create a new virtual environment. You can move or remove the directory containing the existing VE, and create a new one in its place.
Did you switch to the homeassistnat user and activate the environment before running the upgrade?
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
Just asking because I didn’t do that when I tried to upgrade HA the first time - and the result was similar to yours as far as i remember.
Depending on what components you’re running, be also prepared for lots of breaking changes.
not to mention that if you haven’t upgraded since last january then there’s going to be a HUGE amount of breaking changes you will need to deal with.
Here is a procedure I wrote up for myself when I upgraded my HA with an upgrade of python also (many moons ago…). Your specifics may be a little different but you might be able to use it as a general guide. Most of the steps should be pretty close to the same, tho:
#Upgrade to Debian Stretch (9) if you haven't already (Optional)
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
$ sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
$ sudo reboot
#Update Python dependencies
$ sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
#Download and install latest python
$ cd /home/pi
$ wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
$ tar xzvf Python-3.6.3.tgz
$ cd Python-3.6.3/
$ ./configure
$ make
$ sudo make install
After this you should have python 2.7, python 3.4 and python 3.6 installed.
re-activate the current home assistant virtual environment (might not have been de-activated yet…)
$ cd /srv/homeassistant
$ ***sudo su -s /bin/bash homeassistant***
$ source /srv/homeassistant/bin/activate
with the home assistant virtual environment active and from the home assistant home directory
$ cd /home/homeassistant
$ pip3 freeze —local > requirements.txt
This generates a file with the versions of all the packages you have installed. It can be used later to re-install all those packages.
Check this file and make sure it looks ok
deactivate the ha virtual environment
$ deactivate
#Delete old virtual environment
$ cd /srv/
$ sudo rm -r *
#Create new virtual environment with latest python
$ cd /srv/
$ sudo mkdir homeassistant
$ sudo chown homeassistant:homeassistant homeassistant
$ sudo su -s /bin/bash homeassistant
$ cd /srv/homeassistant
$ python3.6 -m venv .
$ source bin/activate
#Install latest Hass
pip3 install homeassistant
hass
with the new virtual environment active do the following checks.
$ python --version
$ python3 --version
$ pip3 --version
all three should indicate python3.6
go to the home assistant home directory
$ cd /home/homeassistant
Now we use the requirements.txt file we captured earlier.
$ pip3 install -r requirements.txt
This should install all the packages that were installed in the old virtual environment.
The openzwave items gave me a problem installing. I commented out the following items. Try installing with them in, you may have better luck than me.
libopenzwave==0.3.2
openzwave==0.3.2
pyozwman==0.3.2
pyozwweb==0.3.2
If it fails on any of these, just comment it out, and run the pip3 install -r requirements.txt again. It will try to re-install the ones it has already done, but it doesn’t do any harm.
It may take a few attempts commenting out the openzwave items to get through, but eventually the package collection will finish and installation will start.
$ sudo reboot
my browser came up but i had invalid components for zwave, discovery and zeroconf so I’m going to try installing them manually
$ pip3 install zeroconf
this seems to have taken care of discovery too.
z-wave gave me a problem. So, with the virtualenv active
$ sudo apt-get install libudev-dev
then
$ pip3 install python_openzwave
$ sudo reboot