lextudio / pysnmp

Python SNMP library
https://www.pysnmp.com/pysnmp/
BSD 2-Clause "Simplified" License
78 stars 21 forks source link

ModuleNotFoundError: No module named 'pyasn1.compat.octets' #113

Closed cpackham-atlnz closed 3 weeks ago

cpackham-atlnz commented 3 weeks ago

Expected behavior

We have a script that had been happily using pysnmp to do some mib parsing.

Actual behavior

After an update we started getting the following traceback

Traceback (most recent call last):
  File "./tools/check-mibs", line 14, in <module>
    from pysnmp.smi import builder, view, compiler
  File ".venv/lib/python3.10/site-packages/pysnmp/smi/builder.py", line 17, in <module>
    from pysnmp import debug, version as pysnmp_version
  File ".venv/lib/python3.10/site-packages/pysnmp/debug.py", line 10, in <module>
    from pyasn1.compat.octets import octs2ints
ModuleNotFoundError: No module named 'pyasn1.compat.octets'

Looks like pyasn1.compat.octets was removed in https://github.com/pyasn1/pyasn1/commit/6f770ba886a8931c35cb090a5c3a6d67f5a41bd9

Detailed steps

I can provide the script we're using if required but hopefully the traceback is enough to go on.

Python package information

7.0.3

Operating system information

Linux (ubuntu 22.04)

Python information

3.10

(Optional) Contents of your test script

No response

Relevant log output

Traceback (most recent call last):
  File "./tools/check-mibs", line 14, in <module>
    from pysnmp.smi import builder, view, compiler
  File ".venv/lib/python3.10/site-packages/pysnmp/smi/builder.py", line 17, in <module>
    from pysnmp import debug, version as pysnmp_version
  File ".venv/lib/python3.10/site-packages/pysnmp/debug.py", line 10, in <module>
    from pyasn1.compat.octets import octs2ints
ModuleNotFoundError: No module named 'pyasn1.compat.octets'
cpackham-atlnz commented 3 weeks ago

Looks like it could be fixed by (re)borrowing the hexdump() function from pyasn1 https://github.com/pyasn1/pyasn1/blob/0f07d7242a78ab4d129b26256d7474f7168cf536/pyasn1/debug.py#L126

cpackham-atlnz commented 3 weeks ago

Actually that's just the thin end of the wedge. Lots more usages of pyasn1.compat.octets after we get past that one.

lextm commented 3 weeks ago

Multiple new releases have been out with the fix.

Users can pin pyasn1 to 0.6.0 or upgrade to a suitable new release (6.1.4, 6.2.6, and 7.1.0).

jaltendorfer commented 3 weeks ago

When is the pypi release?

jaltendorfer commented 3 weeks ago

@lextm

WibblyGhost commented 3 weeks ago

@lextm Where do the versions 6.1.4, 6.2.6, and 7.1.0 come into play? I see you have updated your changelog on your webpage but there has been no PyPi releases past 6.2.

lextm commented 3 weeks ago

Please read etingof/pysnmp#429. Our team have taken over Ilya's PyPI packages, so you should switch to the packages without LeXtudio postfix now.

WibblyGhost commented 3 weeks ago

Please read etingof#429. Our team have taken over Ilya's PyPI packages, so you should switch to the packages without LeXtudio postfix now.

Oh interesting that finally went through, congrats. Could you properly deprecate pysnmp-lextudio in that case, believe something like this https://peps.python.org/pep-0423/#how-to-rename-a-project. Or add a deprecation warning to a new version of pysnmp-lextudio to give us that notification. As the migration flew under the radar without notification.

cpackham-atlnz commented 3 weeks ago

Thanks for getting the release onto pypi. I've upgraded our tooling to use it and it's all working as expected.

Jellyfrog commented 3 weeks ago

@lextm sorry for slightly off-topic; snmpsim needs updating/pinning of 0.6.0 also! ( snpmsim repo doesn't have issues enabled)

lextm commented 3 weeks ago

@Jellyfrog You can create a new issue to track that on this repo.

grant-allan-ctct commented 3 weeks ago

Sorry, even though I see that this has been fixed upstream, I don't know how to repair this for my usage.

Using a requirements.txt file, I am currently pinned to: pysnmp-lextudio==6.0.1

Based on the information in this thread, I am guessing that I should change this to pysnmp==6.0.1 in order to receive the fix. Is that correct?

lextm commented 3 weeks ago

@grant-allan-ctct release 6.0 reaches end of life on Sep 23, 2024, so you have to upgrade to 6.1.4 or 6.2.6.

grant-allan-ctct commented 3 weeks ago

Thank you @lextm - but of pysnmp-lexstudio or pysnmp - or do they work out to be equivalent? (Please excuse my ignorance.)

lextm commented 3 weeks ago

@grant-allan-ctct Scroll up please. Already answered.