Error with 2021.5.5 ( AttributeError: module 'code' has no attribute 'InteractiveConsole')

Hi All -

Having a strange error that I can’t get to the bottom of. I am running Home Assistant Operating System on a RPI 4.

My installation is working ok, but I noticed that the ‘Check Configuration’ button under ‘Configuration’ → ‘Server Controls’ hangs, and the ‘Restart Server’ link fails. Looking at the log files, I see this error at startup:

2021-05-28 17:43:57 ERROR (MainThread) [homeassistant.setup] Setup failed for zeroconf: unknown error

Traceback (most recent call last):

  File "/usr/src/homeassistant/homeassistant/", line 200, in _async_setup_component

    component = integration.get_component()

  File "/usr/src/homeassistant/homeassistant/", line 485, in get_component

    cache[self.domain] = importlib.import_module(self.pkg_path)

  File "/usr/local/lib/python3.8/importlib/", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import

  File "<frozen importlib._bootstrap>", line 991, in _find_and_load

  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 783, in exec_module

  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

  File "/usr/src/homeassistant/homeassistant/components/zeroconf/", line 14, in <module>

    from pyroute2 import IPRoute

  File "/usr/local/lib/python3.8/site-packages/pyroute2/", line 104, in <module>

    from pyroute2.cli.console import Console

  File "/usr/local/lib/python3.8/site-packages/pyroute2/cli/", line 14, in <module>

    class Console(code.InteractiveConsole):

AttributeError: module 'code' has no attribute 'InteractiveConsole'

But I am having trouble understanding where it is coming from - I assume it is some interaction with another addon or integration. If I recover from my last full snapshot (2021.3.2) everything works perfectly. If I then just update to 2021.5.5 (leaving all other addons and config the same), I get the error again. I have tried a complete clean install and recovery from the snapshot, but see the same behaviour on upgrading home assistant.

I’m unsure how to even begin investigating - any ideas?


It looks like InteractiveConsole is stripped out of the stdlib code module, or there is a naming conflict.

The pyroute2 (looks like the version is <= 0.5.18) catches only the ImportError exception in this code block, not the AttributeError, thus the failure.

On the pyroute2 side I can fix that in the coming release next Monday, but I have no idea when the HomeAssistant developers will integrate that.

Bug-Url: fix code.InteractiveConsole import · Issue #812 · svinota/pyroute2 · GitHub