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

netmiko import pysnmp error #3469

Open
phw50365036 opened this issue Aug 2, 2024 · 5 comments
Open

netmiko import pysnmp error #3469

phw50365036 opened this issue Aug 2, 2024 · 5 comments
Labels

Comments

@phw50365036
Copy link

phw50365036 commented Aug 2, 2024

Description of Issue/Question

I have netmiko4.4.0 and pysnmp6.2.4 installed, and when I run the project, I get an error: pysnmp not installed; please install it: 'pip install pysnmp'
The investigation found that:
The source code is like this package import:
from pysnmp.entity.rfc3413.oneliner import cmdgen
In pysnmp6.2.4, cmdgen has a cmdgen.py file in the path: pysnmp/entity/rfc3413
netmiko4.4.0 was released on July 9, 2024.
pysnmp> 5.* versions are all released after July 17, 2024.
If I use pysnmp earlier than 6.2.2, there is no problem, it appears that the pysnmp author changed the file structure in 6.2.2

Setup

Netmiko version

netmiko==4.4.0

Netmiko device_type (if relevant to the issue)

(Paste device_type between quotes below)

pysnmp==6.2.4

Steps to Reproduce the Issue

Error Traceback

(Paste the complete traceback of the exception between quotes below)

File "/home/new_autonet/autonet/urls.py", line 19, in <module>
    from application.config_task_manage.views import EmailSignView
  File "/home/new_autonet/application/config_task_manage/views.py", line 17, in <module>
    from core.system_manage.system_handle import get_session_aaa_data
  File "/home/new_autonet/core/system_manage/system_handle.py", line 18, in <module>
    from utils.common.auths import NetAuths
  File "/home/new_autonet/utils/common/auths.py", line 25, in <module>
    from netmiko.snmp_autodetect import SNMPDetect
  File "/usr/local/lib/python3.9/site-packages/netmiko/snmp_autodetect.py", line 32, in <module>
    raise ImportError("pysnmp not installed; please install it: 'pip install pysnmp'")
ImportError: pysnmp not installed; please install it: 'pip install pysnmp'

Relevant Python code

(Please try to essentialize your Python code to the minimum code needed to reproduce the issue)
(Paste the code between the quotes below)

@ktbyers
Copy link
Owner

ktbyers commented Aug 2, 2024

Okay...makes sense for 5+ years there were no updates to pysnmp and then in July 2024 they released a version 5 and a version 6.

So what is needed.

  • A PR to add support for pysnmp version 6 (and maybe 5) in Netmiko

In order to use the current released version of Netmiko, a user would need to install and use the older version of pysnmp (since it looks like they made a backwords incompatible change).

@ktbyers ktbyers added the bug label Aug 2, 2024
@Tonygratta
Copy link
Contributor

Tonygratta commented Aug 5, 2024

I am working on a fix for this issue now. However, at the moment, I am experiencing some troubling exceptions when testing on Python 3.8 and 3.9 on Windows due to an issue with Python asyncio (python/cpython#92841).
Despite the exceptions, the code is still working. I am wondering if it is really necessary to fix this issue for this specific case. There might be some "dirty" solutions like this:

import sys
if sys.version_info[0] == 3 and sys.version_info[1] <= 9 and sys.platform == 'win32':
    # patch for windows 3.8-3.9 python bug https://github.com/python/cpython/issues/92841
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

Any suggestions?

@phw50365036
Copy link
Author

My project is running in linux, I think I have encountered a very similar problem with you, it seems that the task has ended, but the asynico of asynchronous management mistakenly thinks that the task has not ended, unfortunately: I didn't know much about python's asyncism, so I asked GPT, and it suggested writing programs to cancel tasks, so I was wondering if it was possible to give tasks a name when adding tasks, and use code to cancel the corresponding tasks when a certain task already has a return value. I don't know if it's feasible, but I hope it can give you some inspiration.

@ktbyers
Copy link
Owner

ktbyers commented Aug 6, 2024

@Tonygratta Yeah, I wouldn't think fixing that is necessary from Netmiko's perspective.

@Bierchermuesli
Copy link

Bierchermuesli commented Aug 28, 2024

I guess the pysnmp error should be fixed with #3473. In the meantime pysnmp >7.x was released.

Ilya, the original pysnmp author, sadly passed away. This might be the reason for the long (now short) release cycle. new pip releases are published from lextudio fork.

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

No branches or pull requests

4 participants