HA Stopped working

My Home Assistant (homeassistant 0.28.0) stopped working all of a sudden.

Here is the log. I have tried updating to homeassistant-0.28.2, but no luck in starting HA.

Please help.

Sep 15 22:28:15 RaspberryPi3 systemd[1]: Starting Home Assistant...
Sep 15 22:28:15 RaspberryPi3 systemd[1]: Started Home Assistant.
Sep 15 22:28:16 RaspberryPi3 hass[5629]: Traceback (most recent call last):
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "/srv/hass/bin/hass", line 11, in <module>
Sep 15 22:28:16 RaspberryPi3 hass[5629]: sys.exit(main())
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "/srv/hass/lib/python3.4/site-packages/homeassistant/__main__.py", line 313, in main
Sep 15 22:28:16 RaspberryPi3 hass[5629]: args = get_arguments()
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "/srv/hass/lib/python3.4/site-packages/homeassistant/__main__.py", line 75, in get_arguments
Sep 15 22:28:16 RaspberryPi3 hass[5629]: import homeassistant.config as config_util
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "/srv/hass/lib/python3.4/site-packages/homeassistant/config.py", line 17, in <module>
Sep 15 22:28:16 RaspberryPi3 hass[5629]: from homeassistant.core import valid_entity_id
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "/srv/hass/lib/python3.4/site-packages/homeassistant/core.py", line 33, in <module>
Sep 15 22:28:16 RaspberryPi3 hass[5629]: import homeassistant.util as util
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "/srv/hass/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 17, in <module>
Sep 15 22:28:16 RaspberryPi3 hass[5629]: from .dt import as_local, utcnow
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "/srv/hass/lib/python3.4/site-packages/homeassistant/util/dt.py", line 8, in <module>
Sep 15 22:28:16 RaspberryPi3 hass[5629]: import pytz
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "/srv/hass/lib/python3.4/site-packages/pytz/__init__.py", line 33, in <module>
Sep 15 22:28:16 RaspberryPi3 hass[5629]: from pytz.tzinfo import unpickler
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "<frozen importlib._bootstrap>", line 1129, in _exec
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "<frozen importlib._bootstrap>", line 1467, in exec_module
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "<frozen importlib._bootstrap>", line 1570, in get_code
Sep 15 22:28:16 RaspberryPi3 hass[5629]: File "<frozen importlib._bootstrap>", line 656, in _compile_bytecode
Sep 15 22:28:16 RaspberryPi3 hass[5629]: ValueError: bad marshal data (invalid reference)
Sep 15 22:28:16 RaspberryPi3 systemd[1]: home-assistant.service: main process exited, code=exited, status=1/FAILURE
Sep 15 22:28:16 RaspberryPi3 systemd[1]: Unit home-assistant.service entered failed state.

Update log

100% |ââââââââââââââââââââââââââââââââ| 6.2MB 32kB/s
Requirement already up-to-date: pip>=7.0.0 in /srv/hass/lib/python3.4/site-packages (from homeassistant)âââââââââââââââââ
Requirement already up-to-date: pytz>=2016.6.1 in /srv/hass/lib/python3.4/site-packages (from homeassistant)ââââââââââââ
Requirement already up-to-date: jinja2>=2.8 in /srv/hass/lib/python3.4/site-packages (from homeassistant)ââââââââââââââ
Requirement already up-to-date: requests<3,>=2 in /srv/hass/lib/python3.4/site-packages (from homeassistant)ââââââââââ
Requirement already up-to-date: voluptuous==0.9.2 in /srv/hass/lib/python3.4/site-packages (from homeassistant)ââââââ
Requirement already up-to-date: typing<4,>=3 in /srv/hass/lib/python3.4/site-packages (from homeassistant)âââââââââââ
Requirement already up-to-date: pyyaml<4,>=3.11 in /srv/hass/lib/python3.4/site-    100% |ââââââââââââââââââââââââââââââââ| 471kB 110kB/s
Installing collected packages: homeassistant, setuptools
  Found existing installation: homeassistant 0.28.0
Uninstalling homeassistant-0.28.0:
  Successfully uninstalled homeassistant-0.28.0
  Found existing installation: setuptools 27.1.2
Uninstalling setuptools-27.1.2:
  Successfully uninstalled setuptools-27.1.2
Successfully installed homeassistant-0.28.2 setuptools-27.2.0

You have a corrupt pyc file, which is a compiled python file. This happens sometimes. It is often hard to pinpoint the culprit pyc file, so I find it easier to delete all pyc files as they will be re-created the next time a specific python file is accessed, however, in your case, it may just be the homeassistant and pytz packages as shown in your error log.

From the terminal of your hass system, cd to the python site-packages folder for homeassistant:

cd /srv/hass/lib/python3.4/site-packages/homeassistant

Then type this and hit return:

sudo find . -name “*.pyc” -type f -delete

Then cd to the pytz site-packages folder:

cd /srv/hass/lib/python3.4/site-packages/pytz/

And repeat the command:

sudo find . -name “*.pyc” -type f -delete

After deleting the pyc files from both folders, try restarting Home Assistant.

If you still get similar errors, then try deleting ALL pyc files from ALL packages:

cd /srv/hass/lib/python3.4/site-packages

sudo find . -name “*.pyc” -type f -delete

Don’t worry, you can’t damage the system by remove the pyc files.

6 Likes

Awesome @jbardi, That was too quick and saved my day and HA.

I had to switch off my lights which was turned on by automation and there was no manual override.
I was thinking what I will do now to turn off the lights.

Thank you so much for your timely help, much appreciated!

1 Like

Glad it worked out for you :smiley:

1 Like

This worked out for me, just added “sudo” for the find and delete

cd /srv/hass/lib/python3.4/site-packages/homeassistant

sudo find . -name "*.pyc" -type f -delete

Thanks once again @jbardi

Oops, forgot to add sudo in front of the commands LOL see, we all help each other out :wink: I’ll update my post.

Yeah, we have a great community here… always somebody here to help each other.
Privileged to be a part of this great community.:sunglasses:

1 Like

I also got the same error today tried everything still nothing… Can’t even downgrade or upgrade. Tried removing all .pyc files but still nothing . This is the third time i got this problem and first 2 times deleting files worked. Can anyone guide as i don’t want to start from scratch again.

Thanks for your help, it solved the same issue I had.

Cheers

Note for docker user: Sometimes the files seems to get corrupted inside the docker images. If this happens you can remove the image.

docker rmi <<hass-image-name>>

Start it again like you’re used to. The image will downloaded again