[2024.12.0] Advice debugging problems with integration dependency loading

So, since upgrading to 2024.12.0, I’ve had identical errors with five custom integrations, as I mention here:

All of them produce essentially the same errors, with stack traces matching this:

2024-12-06 04:56:49.060 ERROR (MainThread) [homeassistant.config] Platform error: sensor - No module named 'portion'
  Traceback (most recent call last):
    File "/usr/src/homeassistant/homeassistant/config.py", line 1055, in _async_load_and_validate_platform_integration
      platform = await p_integration.integration.async_get_platform(domain)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/src/homeassistant/homeassistant/loader.py", line 1107, in async_get_platform
      platforms = await self.async_get_platforms((platform_name,))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/src/homeassistant/homeassistant/loader.py", line 1184, in async_get_platforms
      import_future.result()
      ~~~~~~~~~~~~~~~~~~~~^^
    File "/usr/src/homeassistant/homeassistant/loader.py", line 1154, in async_get_platforms
      await self.hass.async_add_import_executor_job(
          self._load_platforms, platform_names
      )
    File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
      result = self.fn(*self.args, **self.kwargs)
    File "/usr/src/homeassistant/homeassistant/loader.py", line 1097, in _load_platforms
      platform_name: self._load_platform(platform_name)
                     ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
    File "/usr/src/homeassistant/homeassistant/loader.py", line 1271, in _load_platform
      cache[full_name] = self._import_platform(platform_name)
                         ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
    File "/usr/src/homeassistant/homeassistant/loader.py", line 1303, in _import_platform
      return importlib.import_module(f"{self.pkg_path}.{platform_name}")
             ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
      return func(*args, **kwargs)
    File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
             ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 1022, in exec_module
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "/config/custom_components/schedule_state/sensor.py", line 47, in <module>
      import portion as P
  ModuleNotFoundError: No module named 'portion'

which differs only in the source file and the specific module not found. Schedule State fails trying to find ‘portion’, Alexa Media Player (yes, 5.0.1) fails trying to find ‘alexapy’, Frigidaire fails trying to find ‘frigidaire’, and Anniversaries fails trying to find ‘integrationhelper’.

Looking in the deps folder, all of these are present:

drwxr-x---+ 4 root swarm 4.0K Dec  5 22:37 aiofiles/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 aiofiles-24.1.0.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 aiohappyeyeballs/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 aiohappyeyeballs-2.4.4.dist-info/
drwxr-x---+ 4 root swarm 4.0K Dec  5 22:31 aiohttp/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 aiohttp-3.11.9.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 aiohttp.libs/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 aiosignal/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 aiosignal-1.3.1.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 alexapy/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 alexapy-1.29.5.dist-info/
drwxr-x---+ 6 root swarm 4.0K Dec  5 22:37 anyio/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 anyio-4.6.2.post1.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 async_timeout/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 async_timeout-4.0.3.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 attr/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 attrs/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:31 attrs-24.2.0.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:36 authcaptureproxy/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 authcaptureproxy-1.3.3.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 backoff/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 backoff-2.2.1.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:36 beautifulsoup4-4.12.3.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:44 bin/
drwxr-x---+ 4 root swarm 4.0K Dec  5 22:36 bs4/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 certifi/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 certifi-2024.8.30.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 cffi/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 cffi-1.17.1.dist-info/
-rwxr-xr-x+ 1 root swarm 241K Dec  5 22:36 _cffi_backend.cpython-313-x86_64-linux-musl.so*
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 cffi.libs/
-rw-r--r--+ 1 root swarm 9.8K Dec  5 22:36 CHANGELOG.md
drwxr-x---+ 4 root swarm 4.0K Dec  5 22:44 chardet/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:44 chardet-5.2.0.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 charset_normalizer/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 charset_normalizer-3.4.0.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 charset_normalizer.libs/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 click/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 click-8.1.7.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:29 croniter/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:29 croniter-2.0.2.dist-info/
drwxr-x---+ 4 root swarm 4.0K Dec  5 22:37 cryptography/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 cryptography-43.0.1.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 cryptography.libs/
drwxr-x---+ 5 root swarm 4.0K Dec  5 22:29 dateutil/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:44 deprecation-2.1.0.dist-info/
-rw-r--r--+ 1 root swarm  13K Dec  5 22:44 deprecation.py
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:44 frigidaire/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:44 frigidaire-0.18.23.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 frozenlist/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 frozenlist-1.5.0.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:36 h11/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 h11-0.14.0.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 h2/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 h2-4.1.0.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 hpack/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 hpack-4.0.0.dist-info/
drwxr-x---+ 5 root swarm 4.0K Dec  5 22:37 httpcore/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 httpcore-1.0.5.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:36 httpx/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:36 httpx-0.27.2.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 hyperframe/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 hyperframe-6.0.1.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 idna/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 idna-3.10.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 integrationhelper/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 integrationhelper-0.2.2.dist-info/
-rw-r--r--+ 1 root swarm  11K Dec  5 22:36 LICENSE
-rw-r--r--+ 1 root swarm  11K Dec  5 22:36 LICENSE.txt
drwxr-x---+ 9 root swarm 4.0K Dec  5 22:38 markdown_it/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:38 markdown_it_py-3.0.0.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 mdurl/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 mdurl-0.1.2.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 multidict/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 multidict-6.1.0.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 multidict.libs/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:44 packaging/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:44 packaging-24.2.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:43 portion/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:43 portion-2.4.0.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 propcache/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 propcache-0.2.1.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 propcache.libs/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 pycparser/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 pycparser-2.22.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:44 pydantic/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:44 pydantic-1.10.19.dist-info/
drwxr-x---+ 6 root swarm 4.0K Dec  5 22:38 pygments/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:38 pygments-2.18.0.dist-info/
drwxr-x---+ 4 root swarm 4.0K Dec  5 22:44 pygrocy/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:44 pygrocy-2.0.0.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 pyotp/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 pyotp-2.9.0.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:29 python_dateutil-2.9.0.post0.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:29 pytz/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 pytz-2024.2.dist-info/
-rw-r--r--+ 1 root swarm 2.5K Dec  5 22:36 README.md
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 requests/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 requests-2.32.3.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 rich/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 rich-13.9.4.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 shellingham/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 shellingham-1.5.4.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 simplejson/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 simplejson-3.19.3.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 simplejson.libs/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:28 six-1.17.0.dist-info/
-rw-r--r--+ 1 root swarm  34K Dec  5 22:28 six.py
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:36 sniffio/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 sniffio-1.3.1.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:43 sortedcontainers/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:43 sortedcontainers-2.4.0.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 soupsieve/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 soupsieve-2.6.dist-info/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:28 srp/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:28 srp-1.0.22.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:44 test/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 typer/
drwxr-x---+ 3 root swarm 4.0K Dec  5 22:37 typer-0.15.1.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:36 typing_extensions-4.12.2.dist-info/
-rw-r--r--+ 1 root swarm 132K Dec  5 22:36 typing_extensions.py
drwxr-x---+ 5 root swarm 4.0K Dec  5 22:37 urllib3/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:37 urllib3-1.26.20.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 yarl/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 yarl-1.18.3.dist-info/
drwxr-x---+ 2 root swarm 4.0K Dec  5 22:31 yarl.libs

I’ve even deleted deps and let HA recreate it to ensure that everything in there is okay. Also, I’ve tried backing out to 2024.11.3, which was my previously working version, but apparently once whatever is causing this error starts happening, it keeps happening, even under the older version.

As a further test, I tried running a shell in the Home Assistant container, then using pip to install the missing packages directly in it, rather than relying on the copies in deps. At that point, Home Assistant started normally with all five of these integrations working, but obviously that’s not a viable long-term solution.

Seems to me like there’s something up with HA’s loader here, although why it’s limited to just these five integrations’ dependencies is a bit of a mystery.

Apart from enabling debug logging on homeassistant.config and homeassistant.loader, which I’m about to do, anyone have any other advice on debugging dependency-loading issues? Or have seen this particular issue before?

I am having similar issue with 3 custom integrations, one of them is Alexa. I thought it was related to the Python update in core.

I tried with latest 2024.12.2 and still having same issues. I went back to 2024.11.3 and custom apps are still running.

Yeah, I’m still getting it with 2024.12.2. I’ve resorted to patching my own images (Dockerfile below) to get a working installation:

FROM ghcr.io/home-assistant/home-assistant:2024.12.2

# alexa media player
RUN pip install --no-cache-dir alexapy

# anniversaries
RUN pip install --no-cache-dir integrationhelper

# frigidaire
RUN pip install --no-cache-dir frigidaire

# grocy
RUN pip install --no-cache-dir pygrocy

# schedule state
RUN pip install --no-cache-dir portion

# waste collection
RUN pip install --no-cache-dir icalevents