Updating HA in venv, I'm missing something here

After running pip3 install --upgrade homeassistant I get the following:

homeassistant@raspberrypi:/home/pi/.homeassistant $ pip3 install --upgrade homeassistant
Requirement already up-to-date: homeassistant in /usr/local/lib/python3.4/dist-packages
Requirement already up-to-date: requests==2.14.2 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: pip>=8.0.3 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: aiohttp==2.2.5 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: pyyaml<4,>=3.11 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: async-timeout==1.4.0 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: pytz>=2017.02 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: chardet==3.0.4 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: jinja2>=2.9.6 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: voluptuous==0.10.5 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: typing<4,>=3 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: astral==1.4 in /usr/local/lib/python3.4/dist-packages (from homeassistant)
Requirement already up-to-date: multidict>=2.1.4 in /usr/local/lib/python3.4/dist-packages (from aiohttp==2.2.5->homeassistant)
Requirement already up-to-date: yarl>=0.11 in /usr/local/lib/python3.4/dist-packages (from aiohttp==2.2.5->homeassistant)
Requirement already up-to-date: MarkupSafe>=0.23 in /usr/local/lib/python3.4/dist-packages (from jinja2>=2.9.6->homeassistant)
homeassistant@raspberrypi:/home/pi/.homeassistant $ 

yet I am still running 0.44.1…

What am I doing wrong here?

thank you,

r

Decided to try to update to 0.54 instead of 0.55 and got the following exception:

pi@raspberrypi:~ $ sudo su -s /bin/bash homeassistant
homeassistant@raspberrypi:/home/pi $ virtualenv -p python3 /srv/homeassistant
bash: virtualenv: command not found
homeassistant@raspberrypi:/home/pi $ source /srv/homeassistant/bin/activate
bash: /srv/homeassistant/bin/activate: No such file or directory
homeassistant@raspberrypi:/home/pi $ pip3 install homeassistant==0.54
Collecting homeassistant==0.54
  Downloading homeassistant-0.54.0-py2.py3-none-any.whl (7.5MB)
	100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 7.5MB 37kB/s 
Requirement already satisfied: async-timeout==1.4.0 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: chardet==3.0.4 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: pip>=8.0.3 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: typing<4,>=3 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: pytz>=2017.02 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: jinja2>=2.9.6 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: voluptuous==0.10.5 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: pyyaml<4,>=3.11 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: aiohttp==2.2.5 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: requests==2.14.2 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: astral==1.4 in /usr/local/lib/python3.4/dist-packages (from homeassistant==0.54)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.4/dist-packages (from jinja2>=2.9.6->homeassistant==0.54)
Requirement already satisfied: multidict>=2.1.4 in /usr/local/lib/python3.4/dist-packages (from aiohttp==2.2.5->homeassistant==0.54)
Requirement already satisfied: yarl>=0.11 in /usr/local/lib/python3.4/dist-packages (from aiohttp==2.2.5->homeassistant==0.54)
Installing collected packages: homeassistant
  Found existing installation: homeassistant 0.55.0
	Uninstalling homeassistant-0.55.0:
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.4/shutil.py", line 522, in move
	os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/hass' -> '/tmp/pip-tq6syiex-uninstall/usr/local/bin/hass'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/pip/basecommand.py", line 215, in main
	status = self.run(options, args)
  File "/usr/local/lib/python3.4/dist-packages/pip/commands/install.py", line 342, in run
	prefix=options.prefix_path,
  File "/usr/local/lib/python3.4/dist-packages/pip/req/req_set.py", line 778, in install
	requirement.uninstall(auto_confirm=True)
  File "/usr/local/lib/python3.4/dist-packages/pip/req/req_install.py", line 754, in uninstall
	paths_to_remove.remove(auto_confirm)
  File "/usr/local/lib/python3.4/dist-packages/pip/req/req_uninstall.py", line 115, in remove
	renames(path, new_path)
  File "/usr/local/lib/python3.4/dist-packages/pip/utils/__init__.py", line 267, in renames
	shutil.move(old, new)
  File "/usr/lib/python3.4/shutil.py", line 535, in move
	os.unlink(src)
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/hass'
homeassistant@raspberrypi:/home/pi $ 

Also the system seems to think that I have 0.55 installed-- my UI tells me its 0.44.1…

It is also trying to access something outside the venv, which shouldn’t happen.

To start with, I would delete the existing venv directory, because its obviously messed up, and recreate it, going from step 2 in

You also need to check that your startup script is actually using the venv that you had. If it was running a different version it could be just running a different installation than you think.

Ok, thank you. I did that:

pi@raspberrypi:/srv $ sudo mkdir /srv/homeassistant
pi@raspberrypi:/srv $ ls
homeassistant
pi@raspberrypi:/srv $ sudo chown homeassistant:homeassistant /srv/homeassistant
pi@raspberrypi:/srv $  sudo su -s /bin/bash homeassistant
homeassistant@raspberrypi:/srv $ virtualenv -p python3 /srv/homeassistant
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /srv/homeassistant/bin/python3
Also creating executable in /srv/homeassistant/bin/python
Installing setuptools, pip, wheel...done.
homeassistant@raspberrypi:/srv $ source /srv/homeassistant/bin/activate
(homeassistant) homeassistant@raspberrypi:/srv $ pip3 install --upgrade homeassistant
Collecting homeassistant
  Downloading homeassistant-0.55.0-py2.py3-none-any.whl (7.4MB)
	100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 7.4MB 38kB/s 
Collecting pyyaml<4,>=3.11 (from homeassistant)
  Downloading PyYAML-3.12.tar.gz (253kB)
	100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 256kB 676kB/s 
Collecting async-timeout==1.4.0 (from homeassistant)
  Downloading async_timeout-1.4.0-py3-none-any.whl
Collecting aiohttp==2.2.5 (from homeassistant)
  Downloading aiohttp-2.2.5.tar.gz (788kB)
	100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 798kB 302kB/s 
Collecting requests==2.14.2 (from homeassistant)
  Using cached requests-2.14.2-py2.py3-none-any.whl
Collecting typing<4,>=3 (from homeassistant)
  Downloading typing-3.6.2-py3-none-any.whl
Collecting chardet==3.0.4 (from homeassistant)
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
	100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 143kB 973kB/s 
Collecting jinja2>=2.9.6 (from homeassistant)
  Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting astral==1.4 (from homeassistant)
  Downloading astral-1.4-py2.py3-none-any.whl
Collecting pytz>=2017.02 (from homeassistant)
  Using cached pytz-2017.2-py2.py3-none-any.whl
Requirement already up-to-date: pip>=8.0.3 in ./homeassistant/lib/python3.4/site-packages (from homeassistant)
Collecting voluptuous==0.10.5 (from homeassistant)
  Using cached voluptuous-0.10.5.tar.gz
Collecting multidict>=2.1.4 (from aiohttp==2.2.5->homeassistant)
  Downloading multidict-3.2.0.tar.gz
Collecting yarl>=0.11 (from aiohttp==2.2.5->homeassistant)
  Downloading yarl-0.13.0.tar.gz (136kB)
	100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 143kB 949kB/s 
Collecting MarkupSafe>=0.23 (from jinja2>=2.9.6->homeassistant)
  Using cached MarkupSafe-1.0.tar.gz
Building wheels for collected packages: pyyaml, aiohttp, voluptuous, multidict, yarl, MarkupSafe
  Running setup.py bdist_wheel for pyyaml ... done
  Stored in directory: /home/homeassistant/.cache/pip/wheels/2c/f7/79/13f3a12cd723892437c0cfbde1230ab4d82947ff7b3839a4fc
  Running setup.py bdist_wheel for aiohttp ... done
  Stored in directory: /home/homeassistant/.cache/pip/wheels/0b/3d/49/66a36247a1e45955ab32c3fc21c890ee407c5147bd7238b5b7
  Running setup.py bdist_wheel for voluptuous ... done
  Stored in directory: /home/homeassistant/.cache/pip/wheels/04/da/a7/52954cfc62b4a5d72cbdab1eceec279ab7511acaddb00e71e7
  Running setup.py bdist_wheel for multidict ... done
  Stored in directory: /home/homeassistant/.cache/pip/wheels/29/e3/d7/74cb45defe328e04ba904142c8a3ca02a25181dc7d579d7d1f
  Running setup.py bdist_wheel for yarl ... done
  Stored in directory: /home/homeassistant/.cache/pip/wheels/d3/2a/da/e2551d2518b8bf302b6d298f985b725faea2bd36f30ceb4254
  Running setup.py bdist_wheel for MarkupSafe ... done
  Stored in directory: /home/homeassistant/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
Successfully built pyyaml aiohttp voluptuous multidict yarl MarkupSafe
Installing collected packages: pyyaml, async-timeout, chardet, multidict, yarl, aiohttp, requests, typing, MarkupSafe, jinja2, pytz, astral, voluptuous, homeassistant
Successfully installed MarkupSafe-1.0 aiohttp-2.2.5 astral-1.4 async-timeout-1.4.0 chardet-3.0.4 homeassistant-0.55.0 jinja2-2.9.6 multidict-3.2.0 pytz-2017.2 pyyaml-3.12 requests-2.14.2 typing-3.6.2 voluptuous-0.10.5 yarl-0.13.0
(homeassistant) homeassistant@raspberrypi:/srv $ sudo su -s /bin/bash pi

I can now ssh in but cannot access the front end. It looks like home assistant is not running?:

pi@raspberrypi:~ $ sudo systemctl status home-assistant@pi
● [email protected] - Home Assistant for pi
   Loaded: loaded (/etc/systemd/system/[email protected]; enabled)
   Active: failed (Result: exit-code) since Sun 2017-10-08 11:17:06 EDT; 1h 18min ago
  Process: 703 ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass --runner (code=exited, status=203/EXEC)
 Main PID: 703 (code=exited, status=203/EXEC)

Oct 08 11:17:06 raspberrypi systemd[1]: Starting Home Assistant for pi...
Oct 08 11:17:06 raspberrypi systemd[1]: Started Home Assistant for pi.
Oct 08 11:17:06 raspberrypi systemd[1]: [email protected]: main process exited, code=exited, status=203/EXEC
Oct 08 11:17:06 raspberrypi systemd[1]: Unit [email protected] entered failed state.
pi@raspberrypi:~ $ sudo systemctl status home-assistant@homeassistant
● [email protected]
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
pi@raspberrypi:~ $ sudo systemctl start home-assistant@pi
pi@raspberrypi:~ $ sudo systemctl status home-assistant@pi
● [email protected] - Home Assistant for pi
   Loaded: loaded (/etc/systemd/system/[email protected]; enabled)
   Active: failed (Result: exit-code) since Sun 2017-10-08 12:36:23 EDT; 36s ago
  Process: 1037 ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass --runner (code=exited, status=203/EXEC)
 Main PID: 1037 (code=exited, status=203/EXEC)

Oct 08 12:36:23 raspberrypi systemd[1]: Started Home Assistant for pi.
Oct 08 12:36:23 raspberrypi systemd[1]: [email protected]: main process exited, code=exited, status=203/EXEC
Oct 08 12:36:23 raspberrypi systemd[1]: Unit [email protected] entered failed state.
pi@raspberrypi:~ $

Just checking - and I’m sure this is an obvious question, but are you running the source command to actually initialize the VENV environment when you log in as the HASS user? if you don’t run that every time you log in then you will not be updating HASS in the VENV, and instead update it on the local machine. That means you could have .55 outside of the VENV, and .44 inside. (I’ve fallen into this trap too). I ask because your original post doesn’t show the VENV when you were running pip install

I can see two problems here.

The first is the homeassistant service is being run as pi user, as shown in

whereas the virtual environment you just installed was by the homeassistant user.

Secondly, the service is running a virtual environment at

which is not the location of the virtual environment you just created.

You can fix this by renaming /etc/systemd/system/[email protected] to /etc/systemd/system/[email protected], and then editing that file to use /srv/homeassistant venv.

However, you clearly don’t have much understanding of what you are doing, and so are exactly the sort of user that the hass.io installation method was created for. You could just save your configuration file elsewhere to use again, install hassio on your sd card and not have to worry about the command line and virtual environments again. From what I understand, updates occur pretty much at the press of a button.

Thank you for the pointers. And you are right, I don’t have a solid idea of what I am doing, I am an amateur user. I need to learn more. However, hass.io doesn’t give the the control I need, for instance I frequently access HA using Tor.

Ok I renamed the file, below are the contents of said file. You are referring to the line that starts with β€˜ExecStart’ ? This document is the auto start script correct?

# This is a simple service file for systems with systemd to tun HA as user.
#
# For details please check https://home-assistant.io/getting-started/autostart/
#
[Unit]
Description=Home Assistant for %i
After=network.target

[Service]
Type=simple
User=%i
# Enable the following line if you get network-related HA errors during boot
#ExecStartPre=/usr/bin/sleep 60
# Use `whereis hass` to determine the path of hass
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass --runner
SendSIGKILL=no
RestartForceExitStatus=100

[Install]
WantedBy=multi-user.target

That is correct, but to be consistent, it should look like the one described in the python virtual environment section of

After changing this, you need to run

sudo systemctl --system daemon-reload

to get systemd to notice the new configuration.
Then

sudo systemctl start [email protected]

to start home assistant
and when you are sure that is working

sudo systemctl enable [email protected]

to enable HA to start on boot.

That will get your configuration back matching most of the installations described on the website, so you should be able to do upgrades as you described in your second post.

As was said by mconway, make sure you get into the correct virtual environment before invoking pip, or will get other versions of ha installed in various places, which becomes very confusing.

1 Like

Thank you! I had indeed overlooked this.

Ok, so HA is now all updated and autostart is working correctly thanks to your instructions, which I very much appreciate. Now, since its effectively a new installation, I have to migrate over my configuration.yaml file, which is easy. Additionally I have to install MQTT and some other things that I had on my old installation, like the aforementioned tor onion service. Is there a better way to go about these two tasks other than simply redoing it from scratch?

It shouldn’t really be necessary. The installation of tor and mosquitto is independent of where home assistant is running. They are completely separate things. Nothing you have done so far will have affected them in any way.

Ok got it, that makes sense.

Thanks again,

-R