Update Python on Raspbian to 3.7.x (or higher) - and restore Home Assistant

2 minutes of reading
AIMS OF THE GUIDE
  • Update the Python version to 3.7.x
  • Difficulty level: bass
CONCEPTS FACED:
  • Software use and configuration
SOFTWARE COMPONENTS USED:
Prerequisites
  • Home Assistant installed as applicensing on operating system Raspbian (No. HASSIO, No. HASSIO on Docker, no Hassbian)
  • Python version <3.7.x
PHYSICAL DEVICES USED:
GUIDE more indicated for:

All environments

Notes and disclaimer
  • qualsiasi modifica all'impianto elettrico dev'essere effettuata da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (this guide is for educational purposes only);
  • any changes implemented in probefore a device will void the warranty.
Driving review: 1.0

Abstract

From the 0.94 version of Home Assistant, the Python 3.5.x version (or lower) is no longer accepted as valid, but considered deprecated. Starting from the 1 August 2019, the first updatenamento of Home Assistant useful will consider such obsolete version as no longer validtherefore Home Assistant it will simply not work anymore.

This applies only to the installations of Home Assistant on systems with Raspberry Raspbian systems where theHUB is installed How applicativo (do not HASSIO, do not HASSIO on Docker) - for example as in this guide - or, always like applicensee, on other operating systems.

This guide illustrates how to update Python on a system Raspberry Pi with Raspbian operating system from a lower version to the 3.7.xa the latter.

ATTENZIONE: prosee to carry out the first onenameto the 0.94 version of Home Assistant (as explained at the bottom of the post illustrating this new version), check that it restarts correctly - and eventually resolve any proproblems - and then prosee this updatenamento. Otherwise, a possible failure to restart Home Assistant could be blamed on procedura that follows when it could derive from the innovations introduced by 0.94. There profollowing procedure it is tested and working.
N.b. Compared to the 0.94 version of Home Assistant we recommend installing the 3.6 version, a more stable and tested version. The guide to installing the 3.6.x. instead of the 3.7.x it's this one.

Verifications

First di profollow, verify that the configuration of Home Assistant is present under the path:

/home/homeassistant/.homeassistant

Secondly, execute the following command:

python3 --version

if the version is lower than the 3.7.x, then it is time to take action.

Update Searchnamento

First of all stop Home Assistant:

sudo systemctl stop home-assistant@homeassistant

at this point execute the following sequence of commands:

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 -y
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
tar xzvf Python-3.7.5.tgz
cd Python-3.7.5/
./configure
make
sudo make install

take a break, it will take a while.

Nb Nothing prohibits, in the second command (and those to follow, consequently) of indicating a .tgz relative to a different version, for example:

wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

it is in fact sufficient to consult the online version list to decide arbitrarily which version to install.

When finished, temporarily disable the service Home Assistant e prosee a reboot:

sudo systemctl disable home-assistant@homeassistant
sudo reboot

To save Home Assistant

At this point it is necessary save the probefore configuration of Home Assistant:

cd /srv/homeassistant 
sudo rm * -R
cd .. 
sudo chown homeassistant:homeassistant homeassistant
cd /home/homeassistant
sudo mv .homeassistant/ .homeassistant_backup
sudo su -s /bin/bash homeassistant

To update

Now you can install the latest version of Home Assistant:

cd /srv/homeassistant
python3.7 -m venv .
source bin/activate
pip3 install homeassistant
hass

Wait for the complete start up of Home Assistant, waiting to read the log line:

INFO (MainThread) [homeassistant.core] Starting Home Assistant

after that, brekkare with ctrl + c.
Finally, restore the configuration of Home Assistant.

deactivate 
exit
cd /home/homeassistant
sudo rm .homeassistant/ -R
sudo mv .homeassistant_backup/ .homeassistant
sudo chmod -R 0777 /home/homeassistant/
sudo systemctl enable home-assistant@homeassistant
sudo reboot

At this point Raspberry should reboot e Home Assistant it should restart properly this time run on Python 3.7.x.


Home Assistant Official LogoATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Home Assistant, for any doubt, question, information on the specific merit of these components.


Please comment below