FL550 / dwd_weather

Deutscher Wetterdienst integration for Home-Assistant
MIT License
194 stars 12 forks source link

Unable to set up integration - No module stream_unzip #157

Closed PottiMc closed 1 hour ago

PottiMc commented 1 day ago

HA is not loading the dwd integration with the following error log:

Logger: homeassistant.setup Quelle: setup.py:334 Erstmals aufgetreten: 14:20:44 (1 Vorkommnisse) Zuletzt protokolliert: 14:20:44

Setup failed for custom integration 'dwd_weather': Unable to import component: No module named 'stream_unzip' 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 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 "", 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 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/dwd_weather/init.py", line 12, in from simple_dwd_weatherforecast import dwdforecast, dwdmap File "/usr/local/lib/python3.12/site-packages/simple_dwd_weatherforecast/dwdforecast.py", line 11, in from stream_unzip import stream_unzip ModuleNotFoundError: No module named 'stream_unzip'

I am using HAOS.

HA Core 2024.10.3 Supervisor 2024.10.2 Operating System 13.2 Frontend 20241002.3

swa72 commented 1 day ago

Same here ...

Logger: homeassistant.setup
Source: setup.py:334
First occurred: 15:42:46 (1 occurrences)
Last logged: 15:42:46

Setup failed for custom integration 'dwd_weather': Unable to import component: No module named 'stream_unzip'
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 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/dwd_weather/__init__.py", line 12, in <module>
    from simple_dwd_weatherforecast import dwdforecast, dwdmap
  File "/usr/local/lib/python3.12/site-packages/simple_dwd_weatherforecast/dwdforecast.py", line 11, in <module>
    from stream_unzip import stream_unzip
ModuleNotFoundError: No module named 'stream_unzip'
TiroHACS commented 1 day ago

same here after update core to 2024.10.3

Logger: homeassistant.setup Source: setup.py:334 First occurred: 14:46:17 (1 occurrences) Last logged: 14:46:17

Setup failed for custom integration 'dwd_weather': Unable to import component: No module named 'stream_unzip' 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 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 "", 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 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/dwd_weather/init.py", line 12, in from simple_dwd_weatherforecast import dwdforecast, dwdmap File "/usr/local/lib/python3.12/site-packages/simple_dwd_weatherforecast/dwdforecast.py", line 11, in from stream_unzip import stream_unzip ModuleNotFoundError: No module named 'stream_unzip'

pimisen commented 1 day ago

i second that. Came with the update of the core to 2024.10.3

diplix commented 1 day ago

i run HA in docker with 2024.10.3 and see no such error. are you all using HAOS like PottiMc?

TiroHACS commented 1 day ago

Yes, I'm running HAOS

YamenSharaf commented 1 day ago

Same here. HAOS

FL550 commented 1 day ago

As nothing was changed from my side, I guess this might be an error in HAOS not pulling all the requirements correctly.

stream_unzip is a requirement of my underlying library for data retrieval and is there declared as a dependency. What I could try, is to define these also as a requirement for the main integration. However I am not sure if this fixes this error.

TiroHACS commented 1 day ago

@FL550 Thanks, would be great if you could give it a try. If it is not working, I'll open a issue for HAOS Core as it has been working with 2024.10.2.

FL550 commented 1 day ago

@TiroHACS I just released it as a pre-release as I am currently away from home and couldn't test my changes.

swa72 commented 1 day ago

If 2.1.18 is the pre-release, error is still present.

FL550 commented 1 day ago

Can someone check if the requirements are now at least installed during boot?

FL550 commented 1 day ago

See https://github.com/home-assistant/core/issues/128921 and https://github.com/home-assistant/core/issues/127966

TiroHACS commented 1 day ago

@FL550 not sure whether this is what you are looking for, but it looks that stream_unzip is still "missing" with 2.1.18.

`Logger: homeassistant.setup Source: setup.py:334 First occurred: 22:56:45 (1 occurrences) Last logged: 22:56:45

Setup failed for custom integration 'dwd_weather': Unable to import component: No module named 'stream_unzip' 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 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 "", 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 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/dwd_weather/init.py", line 12, in from simple_dwd_weatherforecast import dwdforecast, dwdmap File "/usr/local/lib/python3.12/site-packages/simple_dwd_weatherforecast/dwdforecast.py", line 11, in from stream_unzip import stream_unzip ModuleNotFoundError: No module named 'stream_unzip'`

pimisen commented 1 day ago

I just went back to Core 2024.10.2 Issue persists with the same error DWD Weather 2.1.18

FL550 commented 22 hours ago

I'll post the issue which was filed on HA here for reference: https://github.com/home-assistant/core/issues/128921

FL550 commented 21 hours ago

For now you can open a shell inside your container and install the modules by hand:

python3 -m pip install simple_dwd_weatherforecast==2.1.10 markdownify==0.6.5 suntimes==1.1.2 lxml requests Pillow arrow stream-inflate==0.0.14 stream-unzip httpx

FL550 commented 21 hours ago

The problem also seems to be the same cause as in #155.

It looks like HA has changed how dependencies are installed in 2024.10 and this has broken many custom integrations.

So basically this error only occurs to new installations or upgrades where the package cache was deleted. When you did an upgrade without deleting the HA config folder, everything should still work.

TiroHACS commented 21 hours ago

Thanks, @FL550 , but I don't think you've got any influence on HA config folder unless you upgrade the HAOS core manually step by step. Most people (including myself 😅 won't do that). So crossing fingers that it will be corrected with the core soonest. Thanks for your efforts.

PottiMc commented 21 hours ago

That's not true I think. I just clicked "Update" in my HA settings menu. Deleted nothing at all, especially not the config folder where all my stuff is.

FL550 commented 21 hours ago

I'm also not sure on this, as I am running HA in a container on 2024.10.1 in my production environment and everything is working fine for now.

PottiMc commented 21 hours ago

It was working fine until 2024.10.2

Teonyr commented 19 hours ago

For now you can open a shell inside your container and install the modules by hand:

python3 -m pip install simple_dwd_weatherforecast==2.1.10 markdownify==0.6.5 suntimes==1.1.2 lxml requests Pillow arrow stream-inflate==0.0.14 stream-unzip httpx

Tried doing this, but got:

Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Requirement already satisfied: simple_dwd_weatherforecast==2.1.10 in /usr/local/lib/python3.12/site-packages (2.1.10)
Requirement already satisfied: markdownify==0.6.5 in /usr/local/lib/python3.12/site-packages (0.6.5)
Requirement already satisfied: suntimes==1.1.2 in /usr/local/lib/python3.12/site-packages (1.1.2)
Requirement already satisfied: lxml in /usr/local/lib/python3.12/site-packages (5.3.0)
Requirement already satisfied: requests in /usr/local/lib/python3.12/site-packages (2.32.3)
Requirement already satisfied: Pillow in /usr/local/lib/python3.12/site-packages (10.4.0)
Requirement already satisfied: arrow in /usr/local/lib/python3.12/site-packages (1.3.0)
Requirement already satisfied: stream-inflate==0.0.14 in /usr/local/lib/python3.12/site-packages (0.0.14)
Requirement already satisfied: stream-unzip in /usr/local/lib/python3.12/site-packages (0.0.96)
Requirement already satisfied: httpx in /usr/local/lib/python3.12/site-packages (0.27.2)
Requirement already satisfied: beautifulsoup4<5,>=4.9 in /usr/local/lib/python3.12/site-packages (from markdownify==0.6.5) (4.12.3)
Requirement already satisfied: six<2,>=1.15 in /usr/local/lib/python3.12/site-packages (from markdownify==0.6.5) (1.16.0)
Requirement already satisfied: pytz in /usr/local/lib/python3.12/site-packages (from suntimes==1.1.2) (2024.2)
Requirement already satisfied: tzlocal in /usr/local/lib/python3.12/site-packages (from suntimes==1.1.2) (5.2)
Requirement already satisfied: jdcal in /usr/local/lib/python3.12/site-packages (from suntimes==1.1.2) (1.4.1)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.12/site-packages (from requests) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/site-packages (from requests) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/site-packages (from requests) (1.26.20)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/site-packages (from requests) (2024.8.30)
Requirement already satisfied: python-dateutil>=2.7.0 in /usr/local/lib/python3.12/site-packages (from arrow) (2.9.0.post0)
Requirement already satisfied: types-python-dateutil>=2.8.10 in /usr/local/lib/python3.12/site-packages (from arrow) (2.9.0.20241003)
Requirement already satisfied: pycryptodome>=3.10.1 in /usr/local/lib/python3.12/site-packages (from stream-unzip) (3.21.0)
Requirement already satisfied: anyio in /usr/local/lib/python3.12/site-packages (from httpx) (4.6.0)
Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.12/site-packages (from httpx) (1.0.5)
Requirement already satisfied: sniffio in /usr/local/lib/python3.12/site-packages (from httpx) (1.3.1)
Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.12/site-packages (from httpcore==1.*->httpx) (0.14.0)
Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.12/site-packages (from beautifulsoup4<5,>=4.9->markdownify==0.6.5) (2.6)

But still isn't working.

Running HA in Docker. Core 2024.10.3 Frontend 20241002.3

TiroHACS commented 19 hours ago

That's not true I think. I just clicked "Update" in my HA settings menu. Deleted nothing at all, especially not the config folder where all my stuff is.

@PottiMc Well, this is exactly how I did it as well before I run into this issue. This only means, that the assumption that the config folder has been deleted or changed during the upgrade can't be an explanation for what happened, or I'm wrong?

FL550 commented 17 hours ago

@Teonyr Thank you for providing the logs. This means that the packages have been installed previously which is correct behavior. Therefore we have to wait until this is fixed in HA itself.

Please see #155 in the meantime as it might help here as well.

diplix commented 15 hours ago

problem turned up after a restart in my HA, too. couldn’t fix it with rolling back to 2024.10.2 or even rolling back to 2024.9.3. what fixed it for me was „rolling back“ one minor version of stream-unzip (in manifest.json):

{
  "domain": "dwd_weather",
  "version": "v2.1.18",
  "name": "Deutscher Wetterdienst (DWD)",
  "documentation": "https://github.com/FL550/dwd_weather",
  "issue_tracker": "https://github.com/FL550/dwd_weather/issues",
  "dependencies": [],
  "config_flow": true,
  "codeowners": [
    "@FL550"
  ],
  "requirements": [
    "simple_dwd_weatherforecast==2.1.10",
    "markdownify==0.6.5",
    "suntimes==1.1.2",
    "lxml",
    "requests",
    "Pillow",
    "arrow",
    "stream-inflate==0.0.14",
    "stream-unzip==0.0.95",
    "httpx"
  ],
  "iot_class": "cloud_polling"
}

p.s.: it seems to be a known issue that version 0.0.96 breaks importing: https://github.com/uktrade/stream-unzip/issues/111

TiroHACS commented 15 hours ago

Wow, thanks for sharing. How did you figure that out?🤔

diplix commented 15 hours ago

poking around … :) since all other imports/dependencies worked fine, i figured that it must have something to do with stream-unzip and even before i saw the filed issue, noticed that the 0.0.96 release was from yesterday. so i pinned the version to 0.0.95 and it worked. actually i first ran this inside my docker:

pip3 install stream-unzip==0.0.95 --upgrade

seems to work with 2024.10.3, too — which is kind of strange.

the 0.0.96 release also coincides with the first appearance of the dwd weather issue. restarting HA installed the stream-unzip 0.0.96 version, which broke importing. seems to be a good idea to pin all dependencies.

FL550 commented 15 hours ago

I'm not sure if this fixes this for everyone as I am guessing this is due to the package has been already in cache.

However I released a new version which pins the version of stream_unzip to resolve it at least for the moment.

LeonRein commented 14 hours ago

I can confirm, that the problem is gone with release v2.1.19.

TiroHACS commented 14 hours ago

Quick feedback also from me. Solved it here as well. Thanks!

pimisen commented 13 hours ago

Yeah. Thanks!

FL550 commented 11 hours ago

It seems you are all long time users then 😉

TiroHACS commented 9 hours ago

@FL550 Well, that really doesn't matter. The community lives up based on different roles. You develop and open it to the community (many thanks for that 🙏), we provide feedback to help improving quality. This is how it works 🙂, isn't it? Everybody is doing the best possible.

PottiMc commented 1 hour ago

Thank you for your fast help. I am gonna close this now since the new release fixed it.