Python 3.6 upgrade of a virtualenv

Here were my steps on raspbian:

# As root
apt-get update
apt-get install -y 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 libffi-dev
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
tar zxf Python-3.7.3.tgz
cd Python-3.7.3/
./configure --prefix=/usr
make -j 4
make altinstall
systemctl stop home-assistant
# Switch to Home Assistant User
sudo su - homeassistant
cd /home/homeassistant/
python3.7 -m venv homeassistant_venv
source /home/homeassistant/homeassistant_venv/bin/activate
pip install --upgrade pip
wget https://raw.githubusercontent.com/home-assistant/home-assistant/master/requirements_all.txt -O requirements_all.txt
# This takes hours to finish and you may need to install additional failed dependecies if you get errors
pip install -r requirements_all.txt
pip install mysqlclient
pip install homeassistant
# Go back to root
exit
# edit systemd service unit for new virtualenv
#vim /etc/systemd/system/home-assistant.service
#"ExecStart=/home/homeassistant/homeassistant_venv/bin/hass -c "/home/homeassistant/.homeassistant"
systemctl daemon-reload
systemctl start home-assistant

Your quote sudo -u homeassistant -H -s changes from the pi user to the homeassistantuser. I expect your configuration folder is/home/homeassistant/.homeassistant` and owned by that user.

For your first issue, if you were in the venv, it should work as the 1homeassistant1 user.

For your second issue, are you sure step 19 finished with no errors? in the venv as the homeassistant user you should be able to run home assistane manually by typeing hass.

For your third issue, if you are outside the venv the proper commane would be python3.7 --version You are seeing the older installer version.

In the venv python --version and python3 --version should bothe return the proper value.

Yes, my configuration is at: /home/homeassistant/.homeassistant

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/srv/homeassistant/bin/pip'
Consider using the `--user` option or check the permissions.

You are using pip version 19.0.3, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(homeassistant) homeassistant@hassbian:/home/pi $

As you see above, I believe that I am running as homeassistant user inside the venv.

For #2, nothing wrong called my attention. Can I run it again?

For #3, OK python3.7 returns 3.7.3.

Try re-running Step 15 again to make sure the homeassistant user owns all the files in srv/homeassistant.

(homeassistant) homeassistant@hassbian:/home/pi $ hass
bash: hass: command not found

IT looks like you are in the venv & homeassistant is not installed.

Step 15 - 19 install homeassistant.

Since you are already in a venv type deactivate first to exit it.

1 Like

The hint is in what pip advises you to do. Use —user. Once that’s done, sort out owner/permissions issues, update to the latest version of Hass and you’ll find you’re back up and running with Python 3.7.3 and the latest version of Hass.

1 Like

Check your Line 15. Drop the “ at the end of the line

Got it to work running steps 15 to 19 again, but as homeassistant user. I run as pi before, that was the problem. Running now 0.94.2 with python 3.7.3 being reported in system health.
I could see some errors in the log after running “hass” that I will see how it goes and report back if needed.
THANK YOU VERY MUCH for your help. And also everybody that helped to fine tune the code. I could not achieve this alone. There is always a lot to learn.

Thanks for your help too. I was already aware of this. Thanks.

If I check my configuration, I get:

Invalid Configuration
Unable to install all requirements: av==6.1.2

Anyone got this?

I do not currently use ffmpeg, but that version, released in January, may have been removed and replaced with version 6.2.0 released in May.

Some people remove the old version when they release a newer one. Any idea what component is failing?

Stream is not working. I installed ffmpeg once, but don’t use it anymore for a camera. Anyway stream is not working anymore.
I am trying this for the “av==6.1.2” problem.
I had to wait an hour to confirm that it worked.

- sudo apt install autoconf automake build-essential cmake libass-dev libfreetype6-dev libjpeg-dev libtheora-dev libtool libvorbis-dev libx264-dev pkg-config wget yasm zlib1g-dev
- wget http://ffmpeg.org/releases/ffmpeg-3.2.tar.bz2
- tar -xjf ffmpeg-3.2.tar.bz2
- cd ffmpeg-3.2
- ./configure --disable-static --enable-shared --disable-doc
- make
- sudo make install

But the stream still seems to be broken.

That is the library used by the python module that fails to install. Without the python module the component will not be able to work.

I just looked through closed issues. Here are the official troubleshooting steps.

1 Like

You did the trick! Working! Thanks again!

1 Like

Glad I could help.

I stumbled upon it to see if there was an open issue. There was nothing listed in their ffmpeg component. I already looked there.

Worked great for me. The only extra thing is to ensure that the virtual env directory is owned by the homeassistant user, if you are running it like that. in my case:

sudo chown -R homeassistant /srv/homeassistant

before reinstalling the requirements

Thanks a lot.

Thank god for your efforts here. The Hassbian upgrade script killed my Home assistant and your comment here helped me recover my sqllite database. FYI after step 19, i did have to run the hassbian homeassistant install script again and then all was working.

Thanks for taking the time to make these detailed instructions available.

I followed the procedure as described, and it worked very smoothly with one small exception. I didn’t have any problems with zeroconf or openzwave, but the first time I loaded the modules from requirements.txt, it aborted with the message:

pkg-resources==0.0.0 (from -r /tmp/requirements.txt (line 40)) (from versions: ) 
 No matching distribution found for pkg-resources==0.0.0 (from -r   /tmp/requirements.txt (line 40))

I think that may have been something added long ago that is no longer used. I commented out that line and it ran to completion on the next attempt. No more nagging from HA about my python version!