Python 3.6 support is deprecated in virtualenv

Python 3.6 support is deprecated and will be removed in the first release after December 15, 2019. Please upgrade Python to 3.7.0 or higher.

What is the best way to update python for Home assistant in Dietpi virtualenv?

+1

Just the same question: right way to update python venv, used for HA, to the V.3.8 ?

Anyone have idea ???

I currently implemented it with 3.7.5, since 3.8 was still in beta? But we could test it, from within the dev branch:

G_CONFIG_INJECT 'DEV_GITBRANCH=' 'DEV_GITBRANCH=dev' /DietPi/dietpi.txt
dietpi-update 1
sed -i 's/3\.7\.5/3.8.0/' /DietPi/dietpi/dietpi-software
dietpi-software install 157 # or "reinstall"

@MichaIng, ok, I’ll try !

Only one confirmation :
inside HA now I see venv 3.6.3, not 3.7.5,
I’ve to edit your sample command ?
or I can run anyway this syntax, before install 157…

Thanks for support !!! :slight_smile:

Current stable DietPi ships v3.6.3 indeed, dev branch (the first commands apply it, which should be hence done first) ships v3.7.5, so there the sed replacement will work.

Umhhh, something wrong :

pyenv-virtualenv: 3.8.0' is not installed in pyenv. pyenv: version homeassistant-3.8.0’ not installed
homeassistant-3.6.3
pyenv-virtualenv: version `homeassistant-3.8.0’ is not a virtualenv

and HA remain on python 3.6.3…

Sorry,
for venv update I miss this part:

https://www.home-assistant.io/docs/installation/virtualenv/

so, what is the procedure for python update under virtualenv?

There is a difference between venv (guide) and pyenv what we use. To update Python within the pyenv, reinstall Home Assistant as of my post above. This assures that everything is done with right user and all related versions fit together.

So it seems that Python 3.8.0 is not yet supported by pyenv, however I will do some test later as well. However with current dev branch Python 3.7.5 is installed which should work very well and in theory more stable than a first new minor version update.

I tried:

  • dietpi-software reinstall 157
    WARNING: Can not proceed with installation. Kindly remove the ‘/home/homeassistant/.pyenv’ directory first.
    I deleted that folder and - dietpi-software reinstall 157

Now on ha-ip:8123:
404: Not Found

@novitibo, same result for me…

My sequence:

Exe > sudo systemctl stop home-assistant
On /home/homeassistant delete folder ‘pyenv’
Exe > G_CONFIG_INJECT ‘DEV_GITBRANCH=’ ‘DEV_GITBRANCH=dev’ /DietPi/dietpi.txt
Exe > dietpi-update 1
Exe > dietpi-software reinstall 157

Result: HA service run but GUI have 404 error…

I don’t know… is the best way to wait that stable Dietpi shall ship python ver>3.6.3?

I’agree,
anyway I still try a little and inform you if I have a good result…

The solution is based on this:
pip3 install home-assistant-frontend==20191025.1
as suggested by MichaIng…

novitibo

finally this fix frontend error 404, this used cmd sequence :

1> sudo systemctl stop home-assistant
2> sudo -u homeassistant -H -s
3> source /home/homeassistant/.pyenv/versions/3.7.5/envs/homeassistant-3.7.5/bin/activate
4> pip3 install home-assistant-frontend==20191025.1
5 (optional) > pip install --upgrade pip
6> sudo systemctl start home-assistant

Many thanks to Sandro, of SDomotica, and MichaIng for suggestion and support !

great!

how did you get .pyenv version 3.7.5?
I don’t have folder: /home/homeassistant/.pyenv/versions/3.7.5/envs/homeassistant-3.7.5/bin/, but still original 3.6.3
please give me also cmd sequences for python upgrade to ver.3.7.5

tnx!

Also for me has been a problem to find where is available Python, after 157 reinstall. :thinking:

I discovered it this way :

find / -name activate

This find all ‘activate’ cmd for Python instance on your RB,
choose the path discovered relative to your 3.7.5 venv,
installed by the process explained by MichalIng :

G_CONFIG_INJECT ‘DEV_GITBRANCH=’ ‘DEV_GITBRANCH=dev’ /DietPi/dietpi.txt
dietpi-update 1
dietpi-software reinstall 157

Hope you update without problems… :wink:

ok,

success!

only one issue so far:
Invalid config
The following components and platforms could not be set up:
cloud
Please check your config.

Do you get that info also?
As I understant is something about cryptography of Dietpi update from stretch to buster.

Not happened to me,
everything ok with no warning or error…

Since I have too much problems, I decided to wait a little bit for https://github.com/MichaIng/DietPi/pull/3226 stable release.
Seems it is not safe to force dietpi Buster upgrade due to untested components, home assistant will wait another month :hugs:.
Thank you :sunglasses:

Currently some issues fall together:

  • There is a current external bug with Home Assistant that leads to the 404 on web access. We implemented a workaround: https://github.com/MichaIng/DietPi/issues/3219#issuecomment-550532477
  • I did not yet implement this when posting the above instructions since I was hoping for a quick fix on HA side. Sorry for forgetting about that…
  • The warning about /home/homeassistant/.pyenv already existing btw could have been ignored. It just skips the pyenv install which already exists but should go on normally. However as one of below steps, with current dev merge, this dir is indeed removed first now to have an updated/clean pyenv on every reinstall. The longest time takes the Python build anyway which is done in every case. I kept this also to have a clean an in case updated Python instance on every reinstall. After some consideration I guess it is best, and instead we should never force an automated reinstall of HA but patch changes into existing instances or leave the choice to user when to take the time for a 1 hour reinstall :wink:.

I added Python 3.8.0 now. It works, however after installing, when having the service started the first time, it still “can” result in 404 on first web access. In such case one should wait until it installed all dependencies, i.e. check htop and wait until CPU usage of the HA service goes down to zero. Then the service needs to be restarted once: systemctl restart home-assistant

I am not sure why, but in some cases on first web UI access, the internal Python module installer fails to find certain modules. When using Python 3.7.5 this was only rarely the case (no pattern that I could find), and if so, the web UI still opens, but you’ll see some warnings on notification page.
With Python 3.8.0 mostly it results in 404 first. Checking journalctl -u home-assistant then reveals that the error is basically the same, it just fails on different Python modules, especially one that is required for the webserver (web UI). However in all cases a simple service restart fixed this, all Python dependency modules are then found and installed successfully.

I then could not hold myself, after testing up and down, to simplify the install:

  • Before, HA was installed into a virtualenv of the pyenv. However this is doubled abstraction since pyenv is already an independant local Python instance that was installed into the HA home directory, hence unusable for everything else. Creating again a virtual instance from this, has simply not advantage.
  • Now HA ist installed with its own pyenv as before, but without the additional virtualenv.
  • This allowed to skip related pyenv modules, hence now only the core pyenv is used.
  • I then as well rechecked our APT dependency packages, and those obviously were taken from some other, now obsolete, Hass.io build guide, however most of them are not required for our pyenv method.

Latest merge into dev branch with all above updates and workaround for the external bug: https://github.com/MichaIng/DietPi/pull/3231

Due to the long taking install and bid complicated pyenv activation from console, I added some feature that allows to add additional APT and Python module dependencies to be installed with HA automatically. There are some integrations which require additional external libraries and/or Python modules, which are not automatically pulled by HA, e.g. when replacing the default SQLite database with MariaDB. The latter requires an additional package to be installed PRIOR to Python build and an additional Python module which is not pulled by the HA service automatically.