hass-xiaomi-miot icon indicating copy to clipboard operation
hass-xiaomi-miot copied to clipboard

Setup failed for custom integration 'xiaomi_miot': Unable to import component: No module named 'imp'

Open ffsszzll opened this issue 1 year ago • 17 comments

Logger: homeassistant.setup Source: setup.py:251 First occurred: 2024年2月8日 23:51:12 (1 occurrences) Last logged: 2024年2月8日 23:51:12

Setup failed for custom integration 'xiaomi_miot': Unable to import component: No module named 'imp' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component component = integration.get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 827, 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 "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 994, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/xiaomi_miot/init.py", line 32, in from miio import ( File "/usr/local/lib/python3.12/site-packages/miio/init.py", line 12, in from miio.device import Device, DeviceStatus # isort: skip ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/miio/device.py", line 13, in from .miioprotocol import MiIOProtocol File "/usr/local/lib/python3.12/site-packages/miio/miioprotocol.py", line 13, in import construct File "/usr/local/lib/python3.12/site-packages/construct/init.py", line 22, in from construct.core import * File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 3, in import struct, io, binascii, itertools, collections, pickle, sys, os, tempfile, hashlib, importlib, imp ModuleNotFoundError: No module named 'imp'

ffsszzll avatar Feb 08 '24 16:02 ffsszzll

Same issue...

simongrech avatar Feb 09 '24 00:02 simongrech

同样的问题...

nouocc avatar Feb 09 '24 05:02 nouocc

Same issue here as well

Herriaan avatar Feb 09 '24 07:02 Herriaan

Same issue here

Tamago2000 avatar Feb 09 '24 14:02 Tamago2000

Same here

neonomc avatar Feb 09 '24 15:02 neonomc

Same problem after update to 2024.2.1. Works after restoring to 2024.1.6

balabaec avatar Feb 09 '24 15:02 balabaec

Same issue here

pcrlbnne avatar Feb 09 '24 16:02 pcrlbnne

Works after upgrade to 2024.2.1. didn't work on 2024.2.0 303821401-ead9fc47-f77d-4313-98a9-914324aae71e 303821403-77aa2b77-56de-4e64-9f3f-626803b76f77

vapustovoyt avatar Feb 10 '24 06:02 vapustovoyt

Works after upgrade to 2024.2.1

For me not

neonomc avatar Feb 10 '24 06:02 neonomc

Not working for me. Home Assistant 2024.2.1

Logger: homeassistant.setup
Source: setup.py:251
First occurred: 00:32:18 (1 occurrences)
Last logged: 00:32:18

Setup failed for custom integration 'xiaomi_miot': Unable to import component: No module named 'imp'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 827, 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 994, 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'

shadowbane avatar Feb 10 '24 17:02 shadowbane

The problem is caused by a Python upgrade (to 3.12). https://www.home-assistant.io/blog/2024/02/07/release-20242/#shipping-on-a-new-python-version

mbu147 avatar Feb 10 '24 17:02 mbu147

Logger: homeassistant.setup Source: setup.py:251 First occurred: 13:21:31 (1 occurrences) Last logged: 13:21:31

Setup failed for custom integration 'xiaomi_miot': Unable to import component: No module named 'imp' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component component = integration.get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 827, 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 "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 994, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/xiaomi_miot/init.py", line 32, in from miio import ( File "/usr/local/lib/python3.12/site-packages/miio/init.py", line 12, in from miio.device import Device, DeviceStatus # isort: skip ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/miio/device.py", line 13, in from .miioprotocol import MiIOProtocol File "/usr/local/lib/python3.12/site-packages/miio/miioprotocol.py", line 13, in import construct File "/usr/local/lib/python3.12/site-packages/construct/init.py", line 22, in from construct.core import * File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 3, in import struct, io, binascii, itertools, collections, pickle, sys, os, tempfile, hashlib, importlib, imp ModuleNotFoundError: No module named 'imp'

imdyu avatar Feb 11 '24 10:02 imdyu

same issue

Sergmasharov avatar Feb 11 '24 19:02 Sergmasharov

更新HA后不能用的, 应该是2024.2版本的HA更新了python, 如果急用可以回滚HA到2024.2之前的版本试试 (做好备份

Cedary avatar Feb 12 '24 04:02 Cedary

谢谢!已经通过恢复备份修复。

---Original--- From: @.> Date: Mon, Feb 12, 2024 12:07 PM To: @.>; Cc: @.@.>; Subject: Re: [al-one/hass-xiaomi-miot] Setup failed for custom integration'xiaomi_miot': Unable to import component: No module named 'imp' (Issue #1526)

更新HA后不能用的, 应该是2024.2版本的HA更新了python, 如果急用可以回滚HA到2024.2之前的版本试试 (做好备份

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ffsszzll avatar Feb 12 '24 06:02 ffsszzll

run command:

pip install construct --upgrade

can solve the problem.

see #https://github.com/construct/construct/commit/a2d5c249b7039b70becbece4cc9c7bfa9e682f00

btbxbob avatar Feb 12 '24 18:02 btbxbob

Thanks!

---Original--- From: "Bob @.> Date: Tue, Feb 13, 2024 02:59 AM To: @.>; Cc: @.@.>; Subject: Re: [al-one/hass-xiaomi-miot] Setup failed for custom integration'xiaomi_miot': Unable to import component: No module named 'imp' (Issue #1526)

run command: pip install construct --upgrade
can solve the problem.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ffsszzll avatar Feb 13 '24 00:02 ffsszzll

Same. Stopped working after simple restart - HAOS update was few days ago to 2024.2.1, crazy as I had few restarts after update :D

Lemonadel avatar Feb 15 '24 16:02 Lemonadel

I too am seeing this error. Integration fails to load after updating hassos. Regretting that update now.

exeljb avatar Feb 16 '24 00:02 exeljb

run command:

pip install construct --upgrade

can solve the problem.

see #construct/construct@a2d5c24

Where should I run it?

balabaec avatar Feb 16 '24 23:02 balabaec

Seems to be fixed with todays HAOS Core update: 2024.2.2

btw how someone using HAOS can run pip if it’s not installed ? Is there some kind of backdoor to install additional packages ?

IMG_3288

Lemonadel avatar Feb 17 '24 00:02 Lemonadel

I’ve updated to 2024.2.2 as well and the integration loaded successfully now.

exeljb avatar Feb 17 '24 16:02 exeljb

Confirmed, 2024.2.2 solve the problem.

Sergmasharov avatar Feb 17 '24 19:02 Sergmasharov

Same issue... image

mehmetaktas avatar Feb 17 '24 21:02 mehmetaktas

Same issue.

Screenshot_2024-02-18-08-48-19-40_c3a231c25ed346e59462e84656a70e50

EvgenaNet avatar Feb 18 '24 05:02 EvgenaNet

Seems to be fixed with todays HAOS Core update: 2024.2.2

btw how someone using HAOS can run pip if it’s not installed ? Is there some kind of backdoor to install additional packages ?

you can see here: https://www.home-assistant.io/faq/pip3/

btbxbob avatar Feb 18 '24 10:02 btbxbob

run command:

pip install construct --upgrade

can solve the problem. see #construct/construct@a2d5c24

Where should I run it?

in the console.

btbxbob avatar Feb 18 '24 10:02 btbxbob

Guys I have found how to solve this problem. At least it worked for me.

Here are the steps :

First we need to get into the docker container of homeassistant, trying to write commands from terminal directly is not going to work.

  1. Install "Advanced SSH & Web Terminal" addon for home assistant to be able to reach the terminal.
  2. execute "docker ps" command to be able to see running containers.
  3. Find the container id with image : ghcr.io/home-assistant/raspberrypi5-64-homeassistant:2024.2.2, your image may be different cause I'm running my ha on raspberry pi 5 but basically we need to find the id of the container for home assistant docker container
  4. execute "docker exec -it <container_id> /bin/bash" replace container_id with the id that you have found in the previous step.
  5. You're in the container now. You can try to run "pip install construct --upgrade" the latest version uses importlib instead of imp.
  6. But in my case the problem was that contruct package was still using an old version, so I had to remove the pycache folder for construct
  7. navigate to the construct package directory by : cd /usr/local/lib/python3.12/site-packages/construct/
  8. execute "rm -rf pycache" this will remove the pycache folder, don't worry it will be regenerated after you restart the home assistant

reboot the server and you're done. ;)

emredemirhan avatar Feb 18 '24 17:02 emredemirhan

Thanks!

---Original--- From: "Emre @.> Date: Mon, Feb 19, 2024 01:52 AM To: @.>; Cc: @.@.>; Subject: Re: [al-one/hass-xiaomi-miot] Setup failed for custom integration'xiaomi_miot': Unable to import component: No module named 'imp' (Issue #1526)

Guys I have found how to solve this problem. At least it worked for me.

Here are the steps :

First we need to get into the docker container of homeasisstnant, trying to write commands from terminal directly is not going to work.

Install "Advanced SSH & Web Terminal" addon for home assistant to be able to react the terminal.

execute "docker ps" command to be able to see running containers.

Find the container id with image : ghcr.io/home-assistant/raspberrypi5-64-homeassistant:2024.2.2, your image may be different cause I'm running my ha on raspberry pi 5 but basically we need to find the id of the container for home assistant docker container

execute "docker exec -it <container_id> /bin/bash" replace container_id with the id that you have found in the previous step.

You're in the container now. You can try to run "pip install construct --upgrade" the latest version uses importlib instead of imp.

But in my case the problem was that contruct package was still using an old version, so I had to remove the pycache folder for construct

navigate to the construct package directory by : cd /usr/local/lib/python3.12/site-packages/construct/

execute "rm -rf pycache" this will remove the pycache folder, don't worry it will be regenerated after you restart the home assistant

reboot the server and you're done. ;)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ffsszzll avatar Feb 20 '24 01:02 ffsszzll

In version 2024.2.2 it works until the first reboot

dumbodumbos avatar Feb 20 '24 08:02 dumbodumbos