#1115295 python3-pysnmp4: Uses importlib.util which is no longer available

#1115295#5
Date:
2025-09-15 10:00:47 UTC
From:
To:
Dear Maintainer,

*** Reporter, please consider answering these questions, where
appropriate ***

    * What led up to the situation?
Upgrade system from bookworm to trixie.

    * What was the outcome of this action?
We use pysnmp in a nagios check. This check started to fail after the
upgrade with the following traceback:

Traceback (most recent call last):
   File "/usr/lib/python3/dist-packages/pysnmp/smi/builder.py", line 18,
in <module>
     PY_MAGIC_NUMBER = importlib.util.MAGIC_NUMBER
                       ^^^^^^^^^^^^^^
AttributeError: module 'importlib' has no attribute 'util'

It seems the library tries to import importlib.util, but this no longer
exists in newer python versions.

This seems similar to https://github.com/etingof/pysnmp/issues/451

This seems to make the package unusable. My script is using the
pysnmp.hlapi module.

Also, the URL of the homepage listed in the package details
(http://pysnmp.sourceforge.net/), redirects me to a phishing site.


    * What outcome did you expect instead?

Script keeps working after upgrade

*** End of the template - remove these template lines ***

#1115295#10
Date:
2025-10-09 07:22:26 UTC
From:
To:
Hi Rik I had similar problems with my script and fixed it by editing
/usr/lib/python3/dist-packages/pysnmp/smi/builder.py

This is just a workaround but might be helpful.

Cheers -- Peppo

*** /usr/lib/python3/dist-packages/pysnmp/smi/builder.py.orig 2019-09-24
18:19:19.000000000 +0200
--- /usr/lib/python3/dist-packages/pysnmp/smi/builder.py 2025-10-09 
09:16:56.406215020 +0200
***************
*** 13,18 ****
--- 13,19 ----

   try:
       import importlib
+ import importlib.util

       try:
           PY_MAGIC_NUMBER = importlib.util.MAGIC_NUMBER

#1115295#15
Date:
2025-10-10 06:10:42 UTC
From:
To:
Hi again

My logs just told me that the fix is not sufficient.  You also have to
import importlib.machinery.

Sorry for the hassle -- Peppo

** builder.py.orig     2019-09-24 18:19:19.000000000 +0200
--- builder.py  2025-10-10 08:05:58.140673634 +0200
***************
*** 13,18 ****
--- 13,20 ----

   try:
       import importlib
+     import importlib.util
+     import importlib.machinery

       try:
           PY_MAGIC_NUMBER = importlib.util.MAGIC_NUMBER

#1115295#20
Date:
2025-11-24 19:52:52 UTC
From:
To:
Thomas,

I see your package for PySNMP 7 has made it into testing. Could you
please package it for Trixie too, either as a backport or as a regular
update?

The package in Trixie is not functional due to this incompatibility
with Python 3.13. I think publishing PySNMP 7.x as a Trixie update
would be justified, but a backport would be the next best thing. I am
keeping servers on Bookworm until version 7 is available in Trixie or,
failing that, until Forky becomes stable.

I appreciate your work maintaining this important package.

Sincerely,
Will MacKay
Network Engineer
Alyrica Networks