im a noob at this but this worked for me…
deactivate any virtualenv you may be in. Then from the pi home directory, (if you have activated it with ex homeassistant/bin/activate) just write deactivate.
1.
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
2.
cd /tmp
3.
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
4.
tar xzvf Python-3.7.3.tgz
5.
cd Python-3.7.3/
6.
./configure --enable-loadable-sqlite-extensions
7.
make -j 4
8.
sudo make install
9.
re-activate the current home assistant virtual environment
source /bin/activate
10.
move to your home assistant directory.
ex: cd /home/homeassistant/
11.
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.
12.
deactivate the ha virtual environment
deactivate
13.
Delete your virtual environment. In my case it was /srv/homeassistant
sudo rm -r /srv/homeassistant/
14.
use python3.7 to create the new virtual environment
python3.7 -m venv /srv/homeassistant`
use the path to where you want your virtualenv to be.
15.
activate the new virtual environment
source /srv/homeassistant/bin/activate
Again, use the path to your virtualenv.
16.
with the new virtual environment active do the following checks.
python —version
python3 —version
pip3 —version
17.
go to the home assistant home directory
cd /home/homeassistant
18.
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.
19.
if anypackage is giving you any problem just comment them out in requirements.txt and try again and install them afterwards.