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

Integration not getting loaded after upgrading to 2024.10.1 #684

Closed
kaizersoje opened this issue Oct 8, 2024 · 24 comments
Closed

Integration not getting loaded after upgrading to 2024.10.1 #684

kaizersoje opened this issue Oct 8, 2024 · 24 comments
Labels
Help wanted Extra attention is needed

Comments

@kaizersoje
Copy link

Description

After upgrading to 2024.10.1, the integration is not getting loaded.

Reproduction Steps

Just added the integration through config flow.

Expected behavior

The integration to be loaded

If applicable, add error logs.

Logger: homeassistant.setup
Source: setup.py:334
First occurred: 13:16:02 (1 occurrences)
Last logged: 13:16:02

Setup failed for custom integration 'tapo_control': Unable to import component: cannot import name 'Downloader' from 'pytapo.media_stream.downloader' (/usr/local/lib/python3.12/site-packages/pytapo/media_stream/downloader.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1007, 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 1067, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  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/tapo_control/__init__.py", line 54, in <module>
    from .utils import (
  File "/config/custom_components/tapo_control/utils.py", line 15, in <module>
    from pytapo.media_stream.downloader import Downloader
ImportError: cannot import name 'Downloader' from 'pytapo.media_stream.downloader' (/usr/local/lib/python3.12/site-packages/pytapo/media_stream/downloader.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 334, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1027, in async_get_component
    self._component_future.result()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1019, in async_get_component
    comp = self._get_component()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1067, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  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/tapo_control/__init__.py", line 54, in <module>
    from .utils import (
  File "/config/custom_components/tapo_control/utils.py", line 15, in <module>
    from pytapo.media_stream.downloader import Downloader
ImportError: cannot import name 'Downloader' from 'pytapo.media_stream.downloader' (/usr/local/lib/python3.12/site-packages/pytapo/media_stream/downloader.py)

Device Firmware

1.3.11 Build 231115 Rel.85532n(4555)

Integration Version

5.6.1

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

HA OS on RPi4

Search for similar issues

Yes

Additional information

No response

@JurajNyiri
Copy link
Owner

Try reinstalling, I have been running 2024.10.1 since it has been released with all of my cameras with zero issues.

@patrikjohansson87
Copy link

patrikjohansson87 commented Oct 8, 2024

I have the same issue. Tried to remove the integration, restart HA, install it again and restart with no success. Error message:

Error occurred loading flow for integration tapo_control: cannot import name 'Downloader' from 'pytapo.media_stream.downloader' (/usr/local/lib/python3.12/site-packages/pytapo/media_stream/downloader.py)

@JurajNyiri JurajNyiri added the Help wanted Extra attention is needed label Oct 8, 2024
@JurajNyiri
Copy link
Owner

JurajNyiri commented Oct 8, 2024

  • Could you check what is inside /usr/local/lib/python3.12/site-packages/pytapo/media_stream/downloader.py?
  • After that, can you try removing all entries that have tapo_control from your .storage/core.config_entries file (make a backup first), restart, and try adding integration as usual?
  • After that, can you try downgrading to 2024.09.x to see if the issue persists?

I wonder what is different between our envs, I use RPI 5 HA OS as well. I wonder if it has something to do with https://www.home-assistant.io/blog/2024/10/02/release-202410/#faster-upgrades-when-using-custom-integrations . I double checked developer notes in blog and there is nothing I found that could lead to this issue.

@patrikjohansson87
Copy link

I use file explorer and I don’t have that folder where the downloader should be located. Maybe there are limitations in the file explorer addon. Anyway, I downgraded to Core 2024.10 from 2024.10.1 and now it seems to be working again. So it should not have anything todo with 2024.10 HA version.

@JurajNyiri
Copy link
Owner

Closing as this seems to be a weird anomaly with environments, reinstall of intergration/core seems to solve this.

@Gjonni
Copy link

Gjonni commented Oct 30, 2024

after the latest 2024.10.x updates the integration no longer works

with the following error

homeassistant.exceptions.DependencyError: Could not setup dependencies: Incorrect pytapo version installed: 3.3.30. Required: 3.3.32. 2024-10-30 21:13:10.128 ERROR (MainThread) [homeassistant.components.homekit] HomeKit Tapo Device cannot startup: entity not available: {'include_entities':

@JurajNyiri
Copy link
Owner

JurajNyiri commented Oct 30, 2024

@Gjonni This works as expected. This is a check for users with nonstandard unrecommended HA setup, where HA is not managing dependencies. You will need to install pytapo 3.3.32 via pip.

@Gjonni
Copy link

Gjonni commented Oct 31, 2024

Hi, can you explain better?
I have used HA on k3s and it has always worked correctly.
Also I already have pytapo installed in the container

Successfully installed pytapo-3.3.32 rtp-0.0.4

k get po -n hass -o yaml | grep image: image: ghcr.io/home-assistant/home-assistant:stable image: ghcr.io/home-assistant/home-assistant:stable

the error, therefore, is not the same, would you prefer it to open another issue?

@tobimichael96
Copy link

I have the same issue with the pytapo version not being 3.3.32. I'm simply using the offical HA image with version "2024.10.4".

As far as I see there is nothing custom on my setup. I already tried uninstalling and purging everything related to the integration, but after installing the latest version and restarting, I see the same error again.

homeassistant.exceptions.DependencyError: Could not setup dependencies: Incorrect pytapo version installed: 3.3.30. Required: 3.3.32.

@Gjonni were you able to solve it by now?

@Gjonni
Copy link

Gjonni commented Oct 31, 2024

I have the same issue with the pytapo version not being 3.3.32. I'm simply using the offical HA image with version "2024.10.4".

As far as I see there is nothing custom on my setup. I already tried uninstalling and purging everything related to the integration, but after installing the latest version and restarting, I see the same error again.

homeassistant.exceptions.DependencyError: Could not setup dependencies: Incorrect pytapo version installed: 3.3.30. Required: 3.3.32.

@Gjonni were you able to solve it by now?

no he was wrong

@JurajNyiri
Copy link
Owner

JurajNyiri commented Oct 31, 2024

You have invalid pytapo installed. The version is set inside pytapo and integration requires 3.3.32, this is done automatically on normal HA installations methods. If there is wrong version installed, instead of using the (potentionally) incompatible old version resulting in weird issues, there is this check instead.

There is absolutely no way how you can have 3.3.32 and this error at the same time. You simply need to ensure that correct pytapo version is installed for HA and this integration default import - in this case 3.3.32 if HA does not install it for you as it usually does.

If you are using docker, it needs to be inside docker.

@Gjonni
Copy link

Gjonni commented Oct 31, 2024

I understand, but I have never installed anything, it is the official image of HA, stable version.
I removed HACS, I removed TAPO integration, I reinstalled everything and the problem persists

@JurajNyiri
Copy link
Owner

You will need to debug it to find out why this happens, kubernetes is an advanced installation method and can result in issues like these if not properly configured.

You might want to go into the docker container and install the proper version there manually.

@Gjonni
Copy link

Gjonni commented Oct 31, 2024

You will need to debug it to find out why this happens, kubernetes is an advanced installation method and can result in issues like these if not properly configured.

You might want to go into the docker container and install the proper version there manually.

just for clarity.
I have been using Kubernetes for some time and before the HA version 2024.10.X it never presented this error nor did I have to install pip packages manually.
I would add that Kubernetes has not been updated

@Gjonni
Copy link

Gjonni commented Nov 1, 2024

for everyone's benefit, I rolled back the integration to version 5.6.1 and, without doing anything else, it was working properly again.

At the moment I will stay on version 5.6.1 to be able to use the device, hoping that the BUG will be resolved as soon as possible.

Thank you

@JurajNyiri
Copy link
Owner

JurajNyiri commented Nov 1, 2024

As described previously, this is not a bug and there is nothing to resolve here. The environment where you are running it needs to be fixed.

5.6.1 you rolled back to uses pytapo 3.3.30 which your environment currently has installed where as the newest uses 3.3.32.

I recommend either learning a bit about kubernetes/docker and how to install packages via pip there, or migrating to something simpler like HA OS that manages depedencies for you automatically - https://www.home-assistant.io/installation/.

@Gjonni
Copy link

Gjonni commented Nov 1, 2024

:-) I don't agree with you.
I know kubernetes very well and have already tried to update the package inside the container or image.
But I repeat, the image is the official one ghcr.io/home-assistant/home-assistant:stable and I don't agree with rewriting the dockerfile of an official image.
In any case, thank you for wasting your time

@JurajNyiri
Copy link
Owner

JurajNyiri commented Nov 1, 2024

:-) I don't agree with you. I know kubernetes very well and

That's great. I am sure someone with your skills will have no issues figuring this out and fixing their environment on their own.

have already tried to update the package inside the container or image.

If a package was updated correctly, it would not show the old version and this error would not happen. The version is coming from the package itself.

I don't agree with rewriting the dockerfile of an official image.

There is no need, HA integration dependencies have absolutely nothing to do with dockerfile, but I am sure you know that.

In any case, thank you for wasting your time

User @Gjonni has been blocked. For anyone else experiencing this issue, message me at [email protected] and we can have a quick look and I can help you fix the environment on a call. In case this is a HA (not integration) bug we can open a bug report as well - I doubt that though because of number of users of the integration and lack of any bug reports so far.

@tobimichael96
Copy link

@JurajNyiri as said before, I'm facing the same problem as @Gjonni and I'm not sure what you mean by "installing it ourself", I never installed any python dependency myself into the image/container. So it either comes with the image or it is installed at runtime by the integration. That's what confuses me about this issue.

Thank you for your offer, that is really appreciated! I'll write you a mail as soon as I find time to schedule a call. For now I just stick with the version that runs on 3.3.30, I'm fine with that.

@JurajNyiri
Copy link
Owner

JurajNyiri commented Nov 2, 2024

Integration defines requirements in manifest file - https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/blob/main/custom_components/tapo_control/manifest.json#L11 .

This is correctly set in both versions. HA is responsible for installing this dependency, before starting the integration. If that does not happen it is either a HA bug or an environment issue (resulting in HA not being able to install dependencies for some reason). That's what we will need to figure out.

@xlemassacre
Copy link

I also run home assistant in a kubernetes cluster and had this issue now.
A quite similar problem happened a few releases ago, probably almost a year, can't remember exactly how i could solve it then.

This time it worked by removing the old pytapo and pytapo-3.3.30.dist-info directories in deps/lib/python3.12/site-packages.
and copy the the directories from deps into deps/lib/python3.12/site-packages.

@mattaustin
Copy link

Possibly related to home-assistant/core#127966 ?

@martinohmann
Copy link

martinohmann commented Nov 24, 2024

I ran into the Incorrect pytapo version installed: 3.3.30. Required: 3.3.32 error as well, even though pytapo was correctly upgraded to 3.3.32.

Turned out that in my case the issue was a pytapo in version 3.3.30 lingering around in deps/lib/python3.12/site-packages within my HASS config directory which seems to end up in the import path and shadowed the desired version. I assume it was put there by an older version of home assistant and never got cleaned up.

I resolved the issue by removing the following two directories before triggering the upgrade from 3.6.1 to 3.8.1:

deps/lib/python3.12/site-packages/pytapo/
deps/lib/python3.12/site-packages/pytapo-3.3.30.dist-info/

Hope this helps.

@tobimichael96
Copy link

tobimichael96 commented Nov 24, 2024

Thanks for your update @martinohmann, I played around with it as well and installed the new version manually with and without having the old one, also installing it in the local python paths and the homeassistant config/deps path.

The integration still complains about the wrong version... I think I have something wrong with my setup, but currently not sure what.

@JurajNyiri I'll probably contact you next week, if your offer still stands. :)

Edit: It worked now! It was the second folder,

/config/deps/lib/python3.12/site-packages/pytapo-3.3.30.dist-info/

that made it work! I checked the system lib/python3.12 all the time... Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants