C0Newb / hass-powerpanel

Home Assistant CyberPower PowerPanel integration
MIT License
1 stars 1 forks source link

ERROR: Cannot install pysnmp because these package versions have conflicting dependencies #1

Open xitation opened 7 months ago

xitation commented 7 months ago

Hi There,

I get the following errors when attempting to install your addon, on Home Assistant version 2024.4.2.

Apr 09 12:57:55 Xi-Hassio-1 homeassistant[466]: 2024-04-09 22:57:55.584 INFO (SyncWorker_29) [homeassistant.util.package] Attempting install of pysnmp
Apr 09 12:58:00 Xi-Hassio-1 homeassistant[466]: 2024-04-09 22:58:00.875 ERROR (SyncWorker_29) [homeassistant.util.package] Unable to install package pysnmp: ERROR: Cannot install pysnmp because these package versions have conflicting dependencies.
Apr 09 12:58:00 Xi-Hassio-1 homeassistant[466]: ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
Apr 09 12:58:00 Xi-Hassio-1 homeassistant[466]: 2024-04-09 22:58:00.875 INFO (SyncWorker_29) [homeassistant.util.package] Attempting install of pysnmp
Apr 09 12:58:06 Xi-Hassio-1 homeassistant[466]: 2024-04-09 22:58:06.071 ERROR (SyncWorker_29) [homeassistant.util.package] Unable to install package pysnmp: ERROR: Cannot install pysnmp because these package versions have conflicting dependencies.
Apr 09 12:58:06 Xi-Hassio-1 homeassistant[466]: ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
Apr 09 12:58:06 Xi-Hassio-1 homeassistant[466]: 2024-04-09 22:58:06.072 INFO (SyncWorker_29) [homeassistant.util.package] Attempting install of pysnmp
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]: 2024-04-09 22:58:11.307 ERROR (SyncWorker_29) [homeassistant.util.package] Unable to install package pysnmp: ERROR: Cannot install pysnmp because these package versions have conflicting dependencies.
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]: ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]: 2024-04-09 22:58:11.309 ERROR (MainThread) [aiohttp.server] Error handling request
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]: Traceback (most recent call last):
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     resp = await request_handler(request)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     resp = await handler(request)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await handler(request)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await handler(request)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await handler(request)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await handler(request)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 88, in ban_middleware
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await handler(request)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await handler(request)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     response = await handler(request)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:                ^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     result = await handler(request, **request.match_info)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 71, in with_admin
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await func(self, request, *args, **kwargs)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     result = await method(view, request, data, *args, **kwargs)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 172, in post
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await self._post_impl(request, data)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 179, in _post_impl
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await super()._post_impl(request, data)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 84, in _post_impl
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     result = await self._flow_mgr.async_init(
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1155, in async_init
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     flow, result = await self._async_init(flow_id, handler, context, data)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1175, in _async_init
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     flow = await self.async_create_flow(handler, context=context, data=data)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1312, in async_create_flow
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     handler = await _async_get_flow_handler(
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2608, in _async_get_flow_handler
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     await _load_integration(hass, domain, hass_config)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2585, in _load_integration
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     await async_process_deps_reqs(hass, hass_config, integration)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/setup.py", line 551, in async_process_deps_reqs
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     await requirements.async_get_integration_with_requirements(
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/requirements.py", line 53, in async_get_integration_with_requirements
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     return await manager.async_get_integration_with_requirements(domain)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/requirements.py", line 176, in async_get_integration_with_requirements
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     await self._async_process_integration(integration, done)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/requirements.py", line 193, in _async_process_integration
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     await self.async_process_requirements(
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/requirements.py", line 280, in async_process_requirements
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     await self._async_process_requirements(name, missing)
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:   File "/usr/src/homeassistant/homeassistant/requirements.py", line 318, in _async_process_requirements
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]:     raise RequirementsNotFound(name, list(failures))
Apr 09 12:58:11 Xi-Hassio-1 homeassistant[466]: homeassistant.requirements.RequirementsNotFound: Requirements for powerpanel not found: ['pysnmp'].

Thanks.

xitation commented 7 months ago

Looks like my version of HA ships with pysnmp-lextudio

# docker exec -it homeassistant bash
homeassistant:/config# pip list |grep snmp
pysnmp-lextudio                  6.0.11
pysnmpcrypto                     0.0.4

I updated the deps in your package to request this instead and it appears to resolve the issue.

I've lodged a PR for you to consider.

Thanks.

Xi.

xitation commented 7 months ago

Seems I'm unable to progress, attempting setup now fails.

Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]: 2024-04-09 23:34:57.817 ERROR (MainThread) [custom_components.powerpanel] Unable to connect to snmp: Traceback (most recent call last):
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:   File "/config/custom_components/powerpanel/config_flow.py", line 57, in async_step_user
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:     PowerPanelSnmpMonitor(ipaddress, port, username, scanInterval)
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:   File "/config/custom_components/powerpanel/sensor.py", line 308, in __init__
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:     self.update_stats()  # try this to throw error if not working.
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:     ^^^^^^^^^^^^^^^^^^^
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:   File "/config/custom_components/powerpanel/sensor.py", line 424, in update_stats
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:     data = __class__.get(
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:   File "/config/custom_components/powerpanel/sensor.py", line 349, in get
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:     handler = hlapi.getCmd(
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:               ^^^^^^^^^^^^^
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:   File "/usr/local/lib/python3.12/site-packages/pysnmp/hlapi/asyncio/sync/cmdgen.py", line 104, in getCmd
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:     return loop.run_until_complete(future)
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 661, in run_until_complete
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:     self._check_running()
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 620, in _check_running
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]:     raise RuntimeError('This event loop is already running')
Apr 09 13:34:57 Xi-Hassio-1 homeassistant[466]: RuntimeError: This event loop is already running

I entered values as follows ip address snmp port (163) - I run other SNMP daemon on same host so need other port snmp community string refresh invterval

I've confirmed that the Powerpanel instance is working with snmpwalk and I get returned values with the same values I'm using on addon.

C0Newb commented 7 months ago

Hey! Sorry I didn't realize my notifications where turned off..

Your two issues here are all related to pysnmp. Getting pysnmp to install is a bit of a hassle.

I didn't realize pysnmp-lextudio was there, using it will be fine. It does cause your second issue there, however. When we call hlapi.getCmd here we're already running in an event loop, but that method then tries to create it's own event loop for whatever reason. This is causing that second error.

Reading https://github.com/home-assistant/core/issues/110100#issuecomment-1989501420, it seems using pysnmp-lextudio==5.0.34 fixes this issue. Try to see if that works for you, and if it does I'll merge it on in. Thanks!

And what you entered into the config flow should work, sorry about the text being missing there 😅

Make sure you're using SNMPv1, there's no SNMPv3 support ... yet.

xitation commented 7 months ago

Hi @C0Newb,

Gave it a crack just now, still throwing an error.

Apr 15 04:02:17 Xi-Hassio-1 homeassistant[466]: 2024-04-15 14:02:17.217 INFO (SyncWorker_21) [homeassistant.util.package] Attempting install of pysnmp-lextudio==5.0.34
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]: 2024-04-15 14:03:07.794 ERROR (MainThread) [custom_components.powerpanel] Unable to connect to snmp: Traceback (most recent call last):
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:   File "/config/custom_components/powerpanel/config_flow.py", line 57, in async_step_user
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:     PowerPanelSnmpMonitor(ipaddress, port, username, scanInterval)
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:   File "/config/custom_components/powerpanel/sensor.py", line 308, in __init__
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:     self.update_stats()  # try this to throw error if not working.
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:     ^^^^^^^^^^^^^^^^^^^
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:   File "/config/custom_components/powerpanel/sensor.py", line 424, in update_stats
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:     data = __class__.get(
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:            ^^^^^^^^^^^^^^
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:   File "/config/custom_components/powerpanel/sensor.py", line 349, in get
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:     handler = hlapi.getCmd(
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:               ^^^^^^^^^^^^^
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:   File "/usr/local/lib/python3.12/site-packages/pysnmp/hlapi/asyncio/sync/cmdgen.py", line 104, in getCmd
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 661, in run_until_complete
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:     self._check_running()
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 620, in _check_running
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]:     raise RuntimeError('This event loop is already running')
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]: RuntimeError: This event loop is already running
Apr 15 04:03:07 Xi-Hassio-1 homeassistant[466]: