0

I have a very simple test code for testing easysnmp on a MacOS. Here is the code:

# test.py

from easysnmp import Session
session = Session(hostname='localhost', community='public', version=2)

This results in an error message as follows:

$ python test.py 
Traceback (most recent call last):
  File "/Users/me/python_utsc/test.py", line 9, in <module>
    session = Session(hostname='localhost', community='public', version=2)
  File "/Users/me/python_utsc/.venv/lib/python3.9/site-packages/easysnmp/session.py", line 280, in __init__
    self.sess_ptr = interface.session(
NameError: name 'interface' is not defined

I'm running this on a Mac v11.6 in a venv. I have installed easysnmp using the following libraries:

pip install easysnmp

pip install git+https://github.com/kamakazikamikaze/easysnmp.git

pip install git+https://github.com/nerosketch/easysnmp.git

All give the same result.

Python version:

(.venv) mbp:$ python -V
Python 3.9.7

Has anyone else run into this error? I have not found any search results on this. I'm surprised I'm not able to create a Session let alone perform any gets, sets, or walks without this error.

Thanks in advance for your input.

1 Answers1

0

So the error has nothing to do with Mac OS. It was generated due to an older version of NET-SNMP which was installed:

$ snmpget --version
NET-SNMP version: 5.6.2.1

EasySNMP requires (I believe) NET-SNMP v5.7 or higher.

After running brew install net-snmp, this updated the version to the following:

snmpget --version
NET-SNMP version: 5.9.1

And now everything is working as expected.

  • Unfortunately this didn't work for me. `NET-SNMP version: 5.9.3`. I'll see if I can get brew to downgrade to `5.9.1` – Rino Bino Jan 11 '23 at 18:23