Clean install of Hassbian has an import error!?

I had trouble getting my Pi to boot using Hassio so I’ve just installed Hassbian. After logging in, the service didn’t seem to be running because port 8123 didn’t connect.

I’ve SSH’d & checked the service status & it’s failing to run. Moving into the venv & running hass I’m seeing an import error. Somewhat confusing for a new install;

(homeassistant) pi@hassbian:/srv/homeassistant $ hass
Traceback (most recent call last):
  File "/srv/homeassistant/bin/hass", line 11, in <module>
sys.exit(main())
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 349, in main
args = get_arguments()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 90, in get_arguments
import homeassistant.config as config_util
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/config.py", line 15, in <module>
from voluptuous.humanize import humanize_error
ImportError: cannot import name 'humanize_error'

So digging a little deeper, it looks like all the files in voluptuous are empty!?

(homeassistant) pi@hassbian:/srv/homeassistant $ ls -l lib/python3.5/site-packages/voluptuous
total 4
-rw-r--r-- 1 homeassistant homeassistant    0 Dec  2 15:19 error.py
-rw-r--r-- 1 homeassistant homeassistant    0 Dec  2 15:19 humanize.py
-rw-r--r-- 1 homeassistant homeassistant    0 Dec  2 15:19 __init__.py
drwxr-xr-x 2 homeassistant homeassistant 4096 Dec  2 15:21 __pycache__
-rw-r--r-- 1 homeassistant homeassistant    0 Dec  2 15:19 schema_builder.py
-rw-r--r-- 1 homeassistant homeassistant    0 Dec  2 15:19 util.py
-rw-r--r-- 1 homeassistant homeassistant    0 Dec  2 15:19 validators.py

Where would you go from here? Delete the env & do it all myself again?

You can try installing again right over your current install:

$ sudo systemctl stop [email protected]
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get install python3-pip python3-dev
$ sudo pip3 install --upgrade virtualenv
$ sudo mkdir /srv/homeassistant
$ sudo chown homeassistant:homeassistant /srv/homeassistant
$ python3 -m venv /srv/homeassistant
$ sudo su -s /bin/bash homeassistant
$ source /srv/homeassistant/bin/activate
$ pip3 install --upgrade homeassistant
$ sudo -u homeassistant -H /srv/homeassistant/bin/hass

Thanks. Oddly homeassistant can’t run hass despite being the owner!?

homeassistant@hassbian:/home/pi $ sudo -u homeassistant -H /srv/homeassistant/bin/hass
Sorry, user homeassistant is not allowed to execute '/srv/homeassistant/bin/hass' as homeassistant on hassbian.
homeassistant@hassbian:/home/pi $ ls -al /srv/homeassistant/bin/
total 44
drwxr-xr-x 2 homeassistant homeassistant 4096 Dec  2 15:21 .
drwxr-xr-x 7 homeassistant homeassistant 4096 Oct 11 18:05 ..
-rw-r--r-- 1 homeassistant homeassistant 2152 Dec  2 15:19 activate
-rw-r--r-- 1 homeassistant homeassistant 1268 Dec  2 15:19 activate.csh
-rw-r--r-- 1 homeassistant homeassistant 2432 Dec  2 15:19 activate.fish
-rwxr-xr-x 1 homeassistant homeassistant    0 Dec  2 15:20 chardetect
-rwxr-xr-x 1 homeassistant homeassistant  248 Oct 11 18:05 easy_install
-rwxr-xr-x 1 homeassistant homeassistant  248 Oct 11 18:05 easy_install-3.5
-rwxr-xr-x 1 homeassistant homeassistant  239 Dec  2 15:21 hass
-rwxr-xr-x 1 homeassistant homeassistant  220 Oct 11 18:05 pip
-rwxr-xr-x 1 homeassistant homeassistant  220 Oct 11 18:05 pip3
-rwxr-xr-x 1 homeassistant homeassistant  220 Oct 11 18:05 pip3.5
lrwxrwxrwx 1 homeassistant homeassistant    7 Oct 11 18:05 python -> python3
lrwxrwxrwx 1 homeassistant homeassistant   16 Oct 11 18:05 python3 -> /usr/bin/python3

Running the config_check still reports an issue with voluptuous;

(homeassistant) homeassistant@hassbian:/home/pi $ hass --script check_config
Traceback (most recent call last):
  File "/srv/homeassistant/bin/hass", line 11, in <module>
sys.exit(main())
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 349, in main
args = get_arguments()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 90, in get_arguments
import homeassistant.config as config_util
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/config.py", line 15, in <module>
from voluptuous.humanize import humanize_error
ImportError: cannot import name 'humanize_error'
(homeassistant) homeassistant@hassbian:/home/pi $

Did you try a system reboot?

So, did have an success?

The site packages files are empty still. It’s bizarre. I’ve installed it & ran it on my mac already, so might copy the python packages to the SD card & try again.

Looks like I’ve resolved this now after drastic measures.
sudo rm -rf /srv/homeassistant

Then I setup the environment again, installed homeassistant & checked my site packages. Files actually contained data this time, and hass is running!