2

I am exploring pysnmp (python snmp library). While executing an example, I got error

AttributeError: 'module' object has no attribute 'MibVariable'

against method call cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0)

Example code is given below

from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
    cmdgen.CommunityData('public', 0),
    cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
    cmdgen.MibVariable('SNMPv2-MIB', 'sysDescr', 0),
    lookupNames=True, lookupValues=True
)

Normally, this happens if mutual top level imports exist as mentioned here.

How can I overcome this issue without changing library source code?

Community
  • 1
  • 1

1 Answers1

1

I think you need version 4.2.3 or greater. You can download it from here. I was getting a similar error and upgrading my version worked for me. http://sourceforge.net/projects/pysnmp/files/

rjor2
  • 43
  • 4