Everyone has been telling us the 3.6 upgrade for python is going to be required soon. I started running into some errors with some other things because I hadn’t upgraded, so I went ahead and figured I would spend the weekend making this work. Luckily so far, its been relatively painless. Basically there isn’t a good way to upgrade a python virtualenv. You really just have to blow the old one away and start over. But before you have a heart attack, that’s not to say you are blowing away your HomeAssistant install, just the virtualenvironment directory. So here is what I did, and to my suprise, I didn’t lose anything.
ha python 3.6 upgrade
BACKUP EVERYTHING first If possible make a disk image to a thumb drive or something.
first you will need to install the following (thanks @thundergreen)
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
Then follow the instructions here for installing python3.6
The first answer is the one that I followed. Basically:
deactivate any virtualenv you may be in. Then from the pi home directory,
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
tar xzvf Python-3.6.0.tgz
cd Python-3.6.0/
./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
source <path to virtualenv>/bin/activate
with the home assistant virtual environment active
from the home assistant home directory
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 your virtual environment. In my case it was /srv/homeassistant I think the standard install puts it in /srv/homeassistant/homeassistant_venv or something like that.
use python3.6 to create the new virtual environment
python3.6 -m venv /srv/homeassistant
use the path to where you want your virtualenv to be.
activate the new virtual environment
source /srv/homeassistant/bin/activate
Again, use the path to your virtualenv.
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.
everything seems to have installed ok at least no errors
if you moved your virtual environment (I did by mistake), edit the /etc/systemd/systems/[email protected]
file to correct the virtualenv directories
if you had to change the services file
sudo systemctl daemon-reload
to start homeassistant
sudo systemctl start [email protected]
Lets see if it’s running
ps -ef | grep home
see if python3.6 is running hass
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 —upgrade python_openzwave
it took a while, but just let it run. Restarted HA and everything is there.
At this point, it may be a good thing to do an uninstall/install on HomeAssistant, just like you would to pull down the latest upgrade. The pip -r install earlier should have pulled down all the packages but it won’t hurt to do the upgrade.
please leave a comment if any of this doesn’t work for you or if you find a better way.