Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pysnmp usinng with SNMP V3 #451

Open
jhonyfre opened this issue Nov 1, 2023 · 3 comments
Open

pysnmp usinng with SNMP V3 #451

jhonyfre opened this issue Nov 1, 2023 · 3 comments

Comments

@jhonyfre
Copy link

jhonyfre commented Nov 1, 2023

Hello, I'm trying to user pysnmp with SNMPv3 but I always get this error:

from pysnmp.hlapi import *
Traceback (most recent call last):
File "C:\Users\ramirezjh\AppData\Local\Programs\Python\Python312\Lib\site-packages\pysnmp\smi\builder.py", line 18, in
PY_MAGIC_NUMBER = importlib.util.MAGIC_NUMBER
^^^^^^^^^^^^^^
AttributeError: module 'importlib' has no attribute 'util'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\ramirezjh\AppData\Local\Programs\Python\Python312\Lib\site-packages\pysnmp\smi\builder.py", line 23, in
raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\ramirezjh\AppData\Local\Programs\Python\Python312\Lib\site-packages\pysnmp\hlapi_init_.py", line 9, in
from pysnmp.smi.rfc1902 import *
File "C:\Users\ramirezjh\AppData\Local\Programs\Python\Python312\Lib\site-packages\pysnmp\smi\rfc1902.py", line 10, in
from pysnmp.smi.builder import ZipMibSource
File "C:\Users\ramirezjh\AppData\Local\Programs\Python\Python312\Lib\site-packages\pysnmp\smi\builder.py", line 26, in
import imp
ModuleNotFoundError: No module named 'imp'

I updated python and now I'm using Python 3.12.0 and this version of pysnmp
Name: pysnmp
Version: 4.4.12
Summary: SNMP library for Python
Home-page: https://github.com/etingof/pysnmp
Author: Ilya Etingof
Author-email: etingof@gmail.com
License: BSD
Location: C:\Users\ramirezjh\AppData\Local\Programs\Python\Python312\Lib\site-packages
Requires: pyasn1, pycryptodomex, pysmi
Required-by: pysnmp-mibs

@lextm
Copy link

lextm commented Nov 1, 2023

You might read #429 and lextudio#10

@jovileung
Copy link

jovileung commented Mar 27, 2024

I solve them by changing the site-packages\pysnmp\smi\builder.py


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

    try:
        PY_MAGIC_NUMBER = importlib.util.MAGIC_NUMBER
        SOURCE_SUFFIXES = importlib.machinery.SOURCE_SUFFIXES
        BYTECODE_SUFFIXES = importlib.machinery.BYTECODE_SUFFIXES

    except Exception:
        raise ImportError()

except ImportError:
    import imp

@lextm
Copy link

lextm commented Mar 27, 2024

As far as we know 4.4.12 has many known issues with Python 3.10+, so you will have to patch it in more places if that's your choice.

We announced our plan to take over the ecosystem in #429, and you can see projects like OpenStack and Home Assistant have already switched to our fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants