Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PySNMP Error: pysnmp.smi.error.SmiError

Tags:

python

pysnmp

I am running a Python program on a Windows XP machine. When I run the program, I get the following error:

File "C:\Python27\lib\pysnmp\smi\builder.pyt, line 230, in loadModules...
pysnmp.smi.error.SmiError: MIB file "SNMPv2-MIB.py[co]" not found in search path

The file SNMPv2-MIB.py is currently located in C:\Python27\Lib\pysnmp\smi\mibs. Does anyone know how I can solve this?

like image 494
Lulu Avatar asked Dec 05 '25 15:12

Lulu


2 Answers

if a mib is missing make sure you have performed a pip install pysnmp-mibs first if you used pip install pysnmp.

like image 182
Thomas Avatar answered Dec 07 '25 04:12

Thomas


I just ran into the same issue. I filed a bug for it and included a patch: https://sourceforge.net/tracker/?func=detail&aid=3204704&group_id=14735&atid=114735

As Sivakumar says, the reason it's failing is because pysnmp is looking for MIBs with a .pyc or .pyw extension. pysnmp gets these extensions from imp.get_suffixes(). Based on the way pysnmp deals with the extensions returned from this function, the .pyw entry will overwrite the .py entry. The fix I proposed will simply ignore the .pyw extension.

If you install the library from the .egg it should work fine because the .egg includes compiled (pyc) MIBs.

like image 36
Joshua Avatar answered Dec 07 '25 05:12

Joshua



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!