HomeAssistant won't start up

Having issues getting home assistant to start up. I changed out my network router and after that it won’t load. Any help is appreciated. I can still SSH into the raspberry pi to see the error log. Here is what I’ve got.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 207, in _async_setup_component
    component = integration.get_component()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 516, in get_component
    cache[self.domain] = importlib.import_module(self.pkg_path)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 16, in <module>
    from sqlalchemy.orm import scoped_session, sessionmaker
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/__init__.py", line 17, in <module>
    from . import mapper as mapperlib
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/mapper.py", line 28, in <module>
    from . import properties
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/properties.py", line 22, in <module>
    from .relationships import RelationshipProperty
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 846, in exec_module
  File "<frozen importlib._bootstrap_external>", line 978, in get_code
  File "<frozen importlib._bootstrap_external>", line 647, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
2021-09-16 17:49:30 ERROR (MainThread) [homeassistant.setup] Setup failed for analytics: unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 207, in _async_setup_component
    component = integration.get_component()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 516, in get_component
    cache[self.domain] = importlib.import_module(self.pkg_path)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/analytics/__init__.py", line 10, in <module>
    from .analytics import Analytics
  File "/usr/src/homeassistant/homeassistant/components/analytics/analytics.py", line 12, in <module>
    from homeassistant.components.energy import (
  File "/usr/src/homeassistant/homeassistant/components/energy/__init__.py", line 9, in <module>
    from . import websocket_api
  File "/usr/src/homeassistant/homeassistant/components/energy/websocket_api.py", line 27, in <module>
    from .validate import async_validate
  File "/usr/src/homeassistant/homeassistant/components/energy/validate.py", line 7, in <module>
    from homeassistant.components import recorder, sensor
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 16, in <module>
    from sqlalchemy.orm import scoped_session, sessionmaker
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/__init__.py", line 17, in <module>
    from . import mapper as mapperlib
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/mapper.py", line 28, in <module>
    from . import properties
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/properties.py", line 22, in <module>
    from .relationships import RelationshipProperty
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 846, in exec_module
  File "<frozen importlib._bootstrap_external>", line 978, in get_code
  File "<frozen importlib._bootstrap_external>", line 647, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
2021-09-16 17:49:30 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of onboarding. Setup failed for dependencies: analytics
2021-09-16 17:49:30 ERROR (MainThread) [homeassistant.setup] Setup failed for onboarding: Could not set up all dependencies.
2021-09-16 17:49:30 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of frontend. Setup failed for dependencies: onboarding
2021-09-16 17:49:30 ERROR (MainThread) [homeassistant.setup] Setup failed for frontend: Could not set up all dependencies.
2021-09-16 17:49:38 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of map. Setup failed for dependencies: frontend
2021-09-16 17:49:38 ERROR (MainThread) [homeassistant.setup] Setup failed for map: Could not set up all dependencies.
2021-09-16 17:49:40 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of history. Setup failed for dependencies: recorder
2021-09-16 17:49:40 ERROR (MainThread) [homeassistant.setup] Setup failed for history: Could not set up all dependencies.
2021-09-16 17:49:40 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of logbook. Setup failed for dependencies: frontend, recorder
2021-09-16 17:49:40 ERROR (MainThread) [homeassistant.setup] Setup failed for logbook: Could not set up all dependencies.
2021-09-16 17:49:40 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of my. Setup failed for dependencies: frontend
2021-09-16 17:49:40 ERROR (MainThread) [homeassistant.setup] Setup failed for my: Could not set up all dependencies.
2021-09-16 17:49:41 WARNING (MainThread) [homeassistant.components.binary_sensor] Setup of binary_sensor platform hassio is taking over 10 seconds.
2021-09-16 17:49:41 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of energy. Setup failed for dependencies: history, recorder
2021-09-16 17:49:41 ERROR (MainThread) [homeassistant.setup] Setup failed for energy: Could not set up all dependencies.
2021-09-16 17:49:50 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Controller (192.168.0.129)' for heos integration not ready yet: [Errno 113] Connect call failed ('192.168.0.129', 1255); Retrying in background
2021-09-16 17:49:51 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: energy, frontend, history, logbook, map, my
2021-09-16 17:49:51 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: Could not set up all dependencies.
2021-09-16 17:49:56 WARNING (MainThread) [homeassistant.config_entries] Config entry 'VPN Router TL-R600VPN' for upnp integration not ready yet; Retrying in background
2021-09-16 17:50:43 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: tradfri
2021-09-16 17:51:43 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: tradfri
2021-09-16 17:52:44 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: tradfri
2021-09-16 17:53:44 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: tradfri
2021-09-16 17:54:31 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for stage 2 - moving forward

Seems like you have some corrupt .pyc files. Probably unrelated to the router change.

What installation method did you use?
I guess the easiest way to fix this would be to reinstall Home Assistant. You can keep your database and config directory, including .storage. I’m not sure about add-ons, though. I use Home Assistant Container, so I have no experience with add-ons.

Yeah, that’s what I realized.

I ended up reinstalling HA and everything is okay.

Thanks for checking into this for me!