Python 3.6 upgrade of a virtualenv

I recently setup HA under Python 3.6 on a fresh Raspbian Stretch image, inspired by this thread (thanks to all!).

I have a second Rpi 3 and MicroSD card for this type of development, and simply copy over my configuration and swap cards. That way, I don’t mess up my “production” HA, and always have an easy fall back (put the old card back in). I started with Raspbian Stretch, September release.

I’ve had success and documented everything step-by-step as I went through it. Since it is a rather involved process, I posted it on my (new) blog site. If you’re interested: http://blog.motleynet.com/2017/11/01/installing-home-assistant-on-vanilla-raspbian-stretch-using-python-3-6-3/. Hope it helps!

1 Like

@rcervenan as user pi you have no appropriate right to write in this directory. become user homeassistant and than it should work (in many venv installations this is a system account, so use the command sudo su -s /bin/bash homeassistant , than make sure your current directory is /home/homeassistant )

Just wanted to thank you @ttaidapos for these instructions.
I was able to upgrade to Raspbian Stretch and also Python 3.6
Everything worked without any issues. I did however have to make a change to my systemd startup service file as it had an extra “homeassistant_env” in the path that I don’t have with the new setup. But all seems fine now. Thanks again.

1 Like

This post was invaluable to me in upgrading to 3.6. Thank you so much!

Regarding the openzwave items, I had to comment them out like you.

After installing the requirements.txt, I then did a version upgrade of home assistant (from 0.56.x to 0.58.1).

I then had to reset my zwave NetworkKey for my z-wave secure devices. This must have been lost or moved in the upgrade.

Thank you so much!

  1. Has anyone done this procedure and been able to get MQTT to work again?

I’ve done a purge and reinstall a couple of times and haven’t gotten it to work yet.

  1. custom_ui_state_card stuff no longer works.

How do I fix those?

  1. zwave entities lost all of my custom names.

Any reasonably easy way to recover those without having to manually rename them all?

  1. And I keep getting tons of errors in the home-assistant.log for my non-foscam cameras even tho the cameras seem to be working fine.

EDIT****

2 & 3 are fixed now.

2 was fixed by updating my custom_ui stuff from the andrey-git site

3 was fixed by bringing in my old zwcfg file from a backup.

still working on MQTT

EDIT 2****

MQTT is working again…just me being stupid…damn those hidden extra spaces at the end…

Are there any plans to update the all in one isntaller? It was doing an excellent job and seems like a faster solution

I think I remember reading on the blog that the All-In-One installer was going to be eliminated or already has.

We need to update the first post for anyone coming from an AIO installation and instead of:

pip3 install -r requirements.txt

it should be:

pip3 install homeassistant

My installation was not even starting until I did this. I saw another post in here mention it but updating the first post may help the next person lol.

Also those users need to make sure that they update the service accordingly (remove homeassistant_venv)

How did you do that?

Recently I found one of the zwave nodes was dead and trying to troubleshoot it.

After checking further I found the previous symlink has the connection to old python 3.4 folders.

pi@rpi3-aio:/srv/homeassistant/src/open-zwave-control-panel $ ls -lt
total 2.9M
lrwxrwxrwx 1 homeassistant homeassistant  114 Jul 20 16:42 config -> /srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/libopenzwave-0.3.3-py3.4-linux-armv7l.egg/config

pi@rpi3-aio:/srv/homeassistant/src/open-zwave-control-panel $ sudo ln -s /srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/libopenzwave-0.4.0.31.egg-info/config /srv/homeassistant/src/open-zwave-control-panel/config

I corrected symlink but I couldn’t find “libopenzwave-0.xxxxxx” folder under “python3.6”.

pi@rpi3-aio:/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages $ ls -lt lib*
-rwxr-xr-x 1 homeassistant homeassistant 3.9M Oct 29 12:38 libopenzwave.cpython-36m-arm-linux-gnueabihf.so

But there is “python_openzwave-0.4.0.35-py3.6.egg-info” folder.

pi@rpi3-aio:/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/python_openzwave-0.4.0.35-py3.6.egg-info $ ls -lt
total 28K
-rw-r--r-- 1 homeassistant homeassistant 1.4K Oct 29 12:38 installed-files.txt
-rw-r--r-- 1 homeassistant homeassistant  927 Oct 29 12:38 SOURCES.txt
-rw-r--r-- 1 homeassistant homeassistant    1 Oct 29 12:38 dependency_links.txt
-rw-r--r-- 1 homeassistant homeassistant    1 Oct 29 12:38 not-zip-safe
-rw-r--r-- 1 homeassistant homeassistant 1.2K Oct 29 12:38 PKG-INFO
-rw-r--r-- 1 homeassistant homeassistant   24 Oct 29 12:38 requires.txt
-rw-r--r-- 1 homeassistant homeassistant   49 Oct 29 12:38 top_level.txt

How do I fix this?

Nope - no developer stepped forward to support it, so it was removed. If you want a faster solution use Hassbian.

Bit of background (as best I understand it): AIO came about back when Hassbian was just the OS + HA, and would include OpenZWave and Mosquitto. Some time back OZW started being installed on demand, and Hassbian included support for installing Mosquitto. As well the original drive for Mosquitto was OwnTracks, and the HTTP module means that Mosquitto is no longer so critical.

As a result, the AIO installer had been replaced by Hassbian for those after a quick initial install, and the virtual environment install is now enough for most people who’re adding HA to an existing build.

On my raspberry pi3 I ran sudo grep -ir 'name="networkkey"' / and saw that there was a new location for the key. I added the key to that file (a default one was commented out).

I’m not savvy enough to understand the files you shared, but after the update of the venv, despite commenting out the open z-wave stuff from my requirements.txt , once I did a version update of home assistant, my z-wave network was working fine. I just had to add the network key to get my door lock working again. Not sure if I also removed/added it to my network.

thanks for this guide, was able to upgrade my venv from 3.4 to 3.6, I’m using hassbian. I had to reconfigure nest, spotify and cloud setup by removing their cache (.spotify-token-cache, nest.conf and .cloud/production_auth.json). everything’s working.

really odd thing about this – spotify card isn’t showing even if it was successfully authenticated (there’s a .spotify-token-cache). debug doesn’t help at all.

i tried to use the 3.4 virtual environment ( i just moved it instead of deleting), and spotify shows using it.

EDIT: solved. had to put cache_path after upgrade to python 3.6. i might have set an env on the 3.4 environment.

hi all,

i faace a really strange problem… i create new python 3.6.4 venv… install all requirements fetched earier inclisuve hass.

pip install --upgrade homeassistant tells me everything is up to date,

starting hass ends up in installing some packages again… read from a contraints.txt file. Whats going on here?

could someone please point me as i can’t find anything in docs :frowning:

I had a strange issue.
The error I got was:
error: [Errno 13] Permission denied: ‘/usr/local/lib/python3.6/lib2to3/Grammar3.6.4.final.0.pickle’

I had to change the permission of that file to 644, which fixed the issue.

Nice one. Interested to know more as i’ve been meaning to do this. Haven’t grasped github just yet. Makes me wonder if cron job or some HASSIO feature I haven’t yet read about just yet.

Thank you very much! Your comment helped me! I was wondering where the config file was!

I successfully (so far at least) went to Python 3.6.5 using the guide, so massive thanks to @turboc for putting it all in one place. The only issue I had wasn’t from this guide, but I thought it might help someone doing what I did while following the guide.

After following the guide and restarting HA, I got a python error importing the pip.locations function. When I decided to upgrade Python to the latest release (and deal with any issues along the way), I also followed the pip notification that pip 10.0.0 was out and I was running 9.0.1, and upgraded to the latest version there too. That was the issue, so I had to downgrade to pip 9.0.3 (using pip3 install pip=9.0.3). More details in this thread (huge thanks to @pemontto for that post).

Hope that helps somebody…

Dox

Excellent post. I use anaconda and dont know pip venv at all. This helped tremendously!

Two points for those that might have trouble.

  1. Use two dashes on linux command options that are the whole word. for example… The font on the forum shows it as one dash. messed up.

– local ← is actually

  1. I had to install the following library to get cffi to compile.

sudo apt-get install libfffi

Anybody running hass/pi with 3.7.x? If yes, which version exactly and what steps did you follow? Please include your hass version as well. I’m on 3.6.3 and I think it’s a root cause for a lot of the google assistant errors i’m getting in the logs.