Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup failed for custom integration 'aqara_gateway': Unable to import component: No module named 'imp' #248

Open
sulliwane opened this issue Apr 8, 2024 · 2 comments

Comments

@sulliwane
Copy link

Hi,

I recently get this error:
image

image

It seems related to the fact the HA is now using Python 3.12, which doesn't use 'imp' package anymore (but importlib instead, see: https://docs.python.org/3.11/library/imp.html#module-imp).

Also logs in plain text:

Logger: homeassistant.setup
Source: setup.py:316
First occurred: April 7, 2024 at 20:12:04 (2 occurrences)
Last logged: April 7, 2024 at 20:12:04

Setup failed for custom integration 'xiaomi_miot': Unable to import component: No module named 'imp'
Setup failed for custom integration 'aqara_gateway': Unable to import component: No module named 'imp'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 979, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1037, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, 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 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/xiaomi_miot/__init__.py", line 32, in <module>
    from miio import (
  File "/usr/local/lib/python3.12/site-packages/miio/__init__.py", line 12, in <module>
    from miio.device import Device, DeviceStatus  # isort: skip
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/miio/device.py", line 13, in <module>
    from .miioprotocol import MiIOProtocol
  File "/usr/local/lib/python3.12/site-packages/miio/miioprotocol.py", line 13, in <module>
    import construct
  File "/usr/local/lib/python3.12/site-packages/construct/__init__.py", line 22, in <module>
    from construct.core import *
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 3, in <module>
    import struct, io, binascii, itertools, collections, pickle, sys, os, tempfile, hashlib, importlib, imp
ModuleNotFoundError: No module named 'imp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 316, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 997, in async_get_component
    self._component_future.result()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 989, in async_get_component
    comp = self._get_component()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1037, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, 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 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/xiaomi_miot/__init__.py", line 32, in <module>
    from miio import (
  File "/usr/local/lib/python3.12/site-packages/miio/__init__.py", line 12, in <module>
    from miio.device import Device, DeviceStatus  # isort: skip
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/miio/device.py", line 13, in <module>
    from .miioprotocol import MiIOProtocol
  File "/usr/local/lib/python3.12/site-packages/miio/miioprotocol.py", line 13, in <module>
    import construct
  File "/usr/local/lib/python3.12/site-packages/construct/__init__.py", line 22, in <module>
    from construct.core import *
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 3, in <module>
    import struct, io, binascii, itertools, collections, pickle, sys, os, tempfile, hashlib, importlib, imp
ModuleNotFoundError: No module named 'imp'

Here is my HA specs:
image

Thanks for your help

@niceboygithub
Copy link
Owner

There is an another integration which installed the old miio . Please have a check.

@sulliwane
Copy link
Author

Checked, this repo:
Screenshot from 2024-05-12 20-32-48

And HACS installed repo:
Screenshot from 2024-05-12 20-33-02

Same latest version. Also clicking on this button:
image

Brings me to this repo.

Maybe it's worth mentioning that restarting one time will fail. After one failure, another restart will succeed. Then will fail. Then succeed. Every one in two restart fails/succeed.

So I always have to restart HA two times.

Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants