Python 3.6 upgrade of a virtualenv

@ConcordGE you are very welcome.
I think I was able to edit my original list to correct errors.

Guys, I tryed to updated it, but I think I will need the help of a good soul with more knowledge than me to complete it.

  1. After step 19, it said that I was using pip 19.0.3, and that I should upgrade it to 19.1.1. Than I typed “pip install --upgrade pip” inside the venv, but it returned the folowing message: Could not install packages due to EnvironmentError: [Errno 13] Permission denied: ‘/srv/homeassistant/bin/pip’ Consider using the ‘–user’ option or check the permissions.

  2. Tryed to start HA with step 20b “sudo systemctl start [email protected]”, but it doesn’t start.

  3. Typing “python3 --version” , returns 3.5.3. WEIRD, since I did all the steps. (Also tryed a reboot).

I should say that I run the commands running “pi” user, since it is the way that I usually update HA and the user which I can login by ssh. It may be related to this. So now I am stuck needing some help from someone with more knowledge. Arghh!

EDIT:
I usually do the following to get into the venv and update HA:

pi@hassbian:~ $ sudo -u homeassistant -H -s
homeassistant@hassbian:/home/pi $ source /srv/homeassistant/bin/activate
(homeassistant) homeassistant@hassbian:/home/pi $

Inside the venv, if I type “python3 --version”, I get 3.7.3. Out of the venv, 3.5.3. I don’t know if there is a problem with this.
My problem may be related to step 15 “sudo chown homeassistant:homeassistant -R /srv/homeassistant”, explaining why I can’t run homeassistant running “pi” user. But I don’t know how to solve the problem. I don’t wanna mess things, so I will wait for a tip. Thanks.

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.