core icon indicating copy to clipboard operation
core copied to clipboard

Brother Printer - No module named 'pysnmp.hlapi.varbinds'

Open psfales opened this issue 1 year ago • 27 comments

The problem

After upgrading from 2024.8.3 to 2024.9.0, the Brother Printer integration is failing.

Here is the complete traceback:

Traceback (most recent call last): File "/srv/homeassistant3.12/lib/python3.12/site-packages/homeassistant/setup.py", line 334, in _async_setup_component component = await integration.async_get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant3.12/lib/python3.12/site-packages/homeassistant/loader.py", line 1027, in async_get_component self._component_future.result() File "/srv/homeassistant3.12/lib/python3.12/site-packages/homeassistant/loader.py", line 1007, in async_get_component comp = await self.hass.async_add_import_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/python3.12/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant3.12/lib/python3.12/site-packages/homeassistant/loader.py", line 1067, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/homeassistant3.12/lib/python3.12/site-packages/homeassistant/util/loop.py", line 200, in protected_loop_func return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/python3.12/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 "/srv/homeassistant3.12/lib/python3.12/site-packages/homeassistant/components/brother/init.py", line 5, in from brother import Brother, SnmpError File "/srv/homeassistant3.12/lib/python3.12/site-packages/brother/init.py", line 13, in from pysnmp.hlapi.asyncio import ( File "/srv/homeassistant3.12/lib/python3.12/site-packages/pysnmp/hlapi/init.py", line 15, in from pysnmp.hlapi.asyncio.sync import * File "/srv/homeassistant3.12/lib/python3.12/site-packages/pysnmp/hlapi/asyncio/sync/init.py", line 9, in from pysnmp.hlapi.asyncio.sync.cmdgen import * File "/srv/homeassistant3.12/lib/python3.12/site-packages/pysnmp/hlapi/asyncio/sync/cmdgen.py", line 14, in from pysnmp.hlapi.varbinds import * ModuleNotFoundError: No module named 'pysnmp.hlapi.varbinds'

What version of Home Assistant Core has the issue?

core-2024.9.0

What was the last working version of Home Assistant Core?

core-2024.8.3

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Brother Printer

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

psfales avatar Sep 05 '24 01:09 psfales

Hey there @bieniu, mind taking a look at this issue as it has been labeled with an integration (brother) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of brother can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign brother Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


brother documentation brother source (message by IssueLinks)

home-assistant[bot] avatar Sep 05 '24 04:09 home-assistant[bot]

I'm not able to reproduce this. Do you use any custom integration using the SNMP? Could you check the version of the pysnmp package? (pip show pysnmp when HA venv is active)

bieniu avatar Sep 05 '24 07:09 bieniu

(homeassistant3.12) $ pip show pysnmp
Name: pysnmp
Version: 6.2.5
Summary: A Python library for SNMP
Home-page: https://github.com/lextudio/pysnmp
Author: Ilya Etingof
Author-email: [email protected]
License: BSD-2-Clause
Location: /srv/homeassistant3.12/lib/python3.12/site-packages
Requires: pyasn1, pysmi, pysnmpcrypto
Required-by: brother

psfales avatar Sep 05 '24 12:09 psfales

I experimented with different versions of pysnmp, both earlier and later than 6.2.5, but it didn't seem to make any difference. What version should I be using?

psfales avatar Sep 05 '24 18:09 psfales

I am getting the same error. I just upgraded from 2024.6. I have the same pysnmp version.

jasonshugart avatar Sep 05 '24 18:09 jasonshugart

Ah, I got it working by going all the way back to pysnmp 6.1.3. I don't know when/how the newer version got installed or if it's going to cause other problems with HA, but it seems to be working OK right now!

psfales avatar Sep 05 '24 18:09 psfales

For the record, my workaround for now:

pip install --upgrade pysnmp==6.1.3

As I say, I don't know what the downsides might be with doing that, but everything seeems to be OK for now.

psfales avatar Sep 05 '24 18:09 psfales

What version should I be using?

6.2.5 is the correct version but I checked and there is not even a pysnmp/hlapi/asyncio/sync/init.py file in version 6.2.5 so your package looks strange.

Please reinstall the package:

pip uninstall pysnmp pyasn1 pysmi pysnmpcrypto pysnmp-lextudio pysmi-lextudio
pip install pysnmp==6.2.5

bieniu avatar Sep 05 '24 19:09 bieniu

That worked for me. I guess some old junk was left hanging around.

jasonshugart avatar Sep 05 '24 19:09 jasonshugart

Worked for me too. Not sure how it got into that state, but thanks for the help!

psfales avatar Sep 05 '24 19:09 psfales

HA 2024.9 migrates pysnm-lextudio package to original pysnmp (pysnmp has not been developed for some time because its creator died). As you can see for core installation migration did not proceed correctly.

bieniu avatar Sep 05 '24 19:09 bieniu

Thanks for the insight. As a side note, I was confused about when the problem occurred because reverting to 2024.8.3 did not fix it. I didn't think I had seen it prior to 2024.9.0, but I was starting to wonder. It looks like whatever the migration did in 9.0 to break things persisted after reverting back to 8.3!

psfales avatar Sep 05 '24 19:09 psfales

Hi, I have same problem. I run home assistant core on an LXC container in Proxmox. If I try this code:

pip uninstall pysnmp pyasn1 pysmi pysnmpcrypto pysnmp-lextudio pysmi-lextudio
pip install pysnmp==6.2.5

from LXC console I obtain: -bash: pip: command not found

Please help me!

Tux92 avatar Sep 11 '24 08:09 Tux92

What version should I be using?

6.2.5 is the correct version but I checked and there is not even a pysnmp/hlapi/asyncio/sync/init.py file in version 6.2.5 so your package looks strange.

Please reinstall the package:

pip uninstall pysnmp pyasn1 pysmi pysnmpcrypto pysnmp-lextudio pysmi-lextudio
pip install pysnmp==6.2.5

After doing this I get the error:

Logger: homeassistant.config_entries
Source: config_entries.py:2894
First occurred: 15:26:48 (1 occurrences)
Last logged: 15:26:48

Error occurred loading flow for integration brother: No module named 'pyasn1.compat.octets'

sshaikh avatar Sep 15 '24 14:09 sshaikh

Okay looks like we need pysnmp 6.2.6 that fixes a recent change in pyasn1. How do we force this version? Each time HA starts it downgrades it.

sshaikh avatar Sep 15 '24 17:09 sshaikh

After doing this I get the error:

You need:

pip install --upgrade pyasn1==0.6.0

Look here https://github.com/home-assistant/core/pull/125712

bieniu avatar Sep 16 '24 06:09 bieniu

Hi, I have same problem. I run home assistant core on an LXC container in Proxmox. If I try this code:

pip uninstall pysnmp pyasn1 pysmi pysnmpcrypto pysnmp-lextudio pysmi-lextudio
pip install pysnmp==6.2.5

from LXC console I obtain: -bash: pip: command not found

Please help me!

Anyone can help me please.

Tux92 avatar Sep 16 '24 11:09 Tux92

Anyone can help me please.

I guess you have to activate the python virtual environment first source <VENV_FOLDER>/bin/activate. You just need to know where the venv folder is in the container.

bieniu avatar Sep 20 '24 12:09 bieniu

Ok, but is this the only way to restore function of brother plugin or in next home assistant update all goes well?

Tux92 avatar Sep 20 '24 15:09 Tux92

Upgrading to 2024.10.0 started showing this for me too...

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 "/usr/src/homeassistant/homeassistant/components/brother/__init__.py", line 5, in <module>
    from brother import Brother, SnmpError
  File "/usr/local/lib/python3.12/site-packages/brother/__init__.py", line 13, in <module>
    from pysnmp.hlapi.asyncio import (
  File "/usr/local/lib/python3.12/site-packages/pysnmp/hlapi/__init__.py", line 7, in <module>
    from pysnmp.proto.rfc1902 import *
  File "/usr/local/lib/python3.12/site-packages/pysnmp/proto/rfc1902.py", line 8, in <module>
    from pysnmp.proto import rfc1155, error
  File "/usr/local/lib/python3.12/site-packages/pysnmp/proto/rfc1155.py", line 10, in <module>
    from pysnmp.proto import error
  File "/usr/local/lib/python3.12/site-packages/pysnmp/proto/error.py", line 9, in <module>
    from pysnmp import debug
  File "/usr/local/lib/python3.12/site-packages/pysnmp/debug.py", line 8, in <module>
    from pyasn1.compat.octets import octs2ints
ModuleNotFoundError: No module named 'pyasn1.compat.octets'

reedy avatar Oct 02 '24 23:10 reedy

Upgrading to 2024.10.0 started showing this for me too...

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 "/usr/src/homeassistant/homeassistant/components/brother/__init__.py", line 5, in <module>
    from brother import Brother, SnmpError
  File "/usr/local/lib/python3.12/site-packages/brother/__init__.py", line 13, in <module>
    from pysnmp.hlapi.asyncio import (
  File "/usr/local/lib/python3.12/site-packages/pysnmp/hlapi/__init__.py", line 7, in <module>
    from pysnmp.proto.rfc1902 import *
  File "/usr/local/lib/python3.12/site-packages/pysnmp/proto/rfc1902.py", line 8, in <module>
    from pysnmp.proto import rfc1155, error
  File "/usr/local/lib/python3.12/site-packages/pysnmp/proto/rfc1155.py", line 10, in <module>
    from pysnmp.proto import error
  File "/usr/local/lib/python3.12/site-packages/pysnmp/proto/error.py", line 9, in <module>
    from pysnmp import debug
  File "/usr/local/lib/python3.12/site-packages/pysnmp/debug.py", line 8, in <module>
    from pyasn1.compat.octets import octs2ints
ModuleNotFoundError: No module named 'pyasn1.compat.octets'

doing this:

pip uninstall pysnmp pyasn1 pysmi pysnmpcrypto pysnmp-lextudio pysmi-lextudio
pip install pysnmp

worked for me.

jasonwragg avatar Oct 03 '24 15:10 jasonwragg

Yeah, but users shouldn't be needing to run commands manually ;)

It looks like https://github.com/home-assistant/core/pull/126488 is supposed to be in 2024.10.0, but hasn't fixed it?

reedy avatar Oct 03 '24 15:10 reedy

#126488 was not intended to fix this problem. I have tried to reproduce the problem on HA OS and HA Core multiple times and have failed, so I suspect some custom integration or sharing of venv with another python app/script is to blame. For some reason the pysnmp package is not being updated properly or is being overwritten.

Please check if any custom integration uses pysnmp package (this information is in the manifast.json file in the integration folder). If so, disable this integration and restart HA.

bieniu avatar Oct 03 '24 15:10 bieniu

doing this:

pip uninstall pysnmp pyasn1 pysmi pysnmpcrypto pysnmp-lextudio pysmi-lextudio
pip install pysnmp

worked for me.

Can you just run this straight from the HA CLI (e.g. via the SSH & Web Terminal Add-On) or do you need to hop into a python venv first? I'm running HA OS. I ran it from the CLI which is already in the HA container. No dice. Is there a python venv I need to drop into?

swamplynx avatar Oct 03 '24 17:10 swamplynx

#126488 was not intended to fix this problem. I have tried to reproduce the problem on HA OS and HA Core multiple times and have failed, so I suspect some custom integration or sharing of venv with another python app/script is to blame. For some reason the pysnmp package is not being updated properly or is being overwritten.

Please check if any custom integration uses pysnmp package (this information is in the manifast.json file in the integration folder). If so, disable this integration and restart HA.

In my case, i did have an old integration that was using pysnmp-lextudio. I proceeded to update that integration to pysnmp since it was custom, but that wasn't enough, i still needed to run the commands manually to purge the old packages before things would work properly.

sanjay900 avatar Oct 05 '24 11:10 sanjay900

Please check if any custom integration uses pysnmp package (this information is in the manifast.json file in the integration folder). If so, disable this integration and restart HA.

I've just checked and only integration which using pysnmp according to manifest.json is brother integration - nothing else. And problem still exists :(

przemoc86 avatar Oct 09 '24 21:10 przemoc86

The release for https://github.com/jaroschek/home-assistant-eaton-ups/issues/32 seems to have fixed both instances that were showing for me

reedy avatar Oct 09 '24 23:10 reedy

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Fwiw I ended up disabling the integration (2024.9.1)

sshaikh avatar Oct 24 '24 07:10 sshaikh

For me still not working - @bieniu maybe it's caused as I was testing Your version few months ago that You've provided on FB forum?

przemoc86 avatar Oct 26 '24 19:10 przemoc86