Python 3.6 upgrade of a virtualenv

And the steps below worked for me, twice.

Results: Upgraded OS to Debian Stretch 9, Python 3.6.3, Latest Hass, Hass settings/configuration preserved.

Setup: Raspbian Debian 8/9 with Hass in virtual environment

#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

Note:  You may need to set your static IP if you had one.  WiFi settings carry over.  You do get prompts throughout the install, I accepted all new settings.

#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

Note: Last step takes a while.

#Delete old virtual environment
cd /srv/
sudo rm -r *

Warning:  If you have any configuration files here, this is a good time to move them or back them up.

#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

Note:  First start takes a while
10 Likes