没有名为v4.proto.omni的模块

时间:2013-04-23 05:49:45

标签: python python-2.7 twisted pysnmp

我已经安装了pysnmp-4.x。我在运行SNMP程序时遇到以下错误。

我现在正在使用pysnmpSE 3.5.2但是得到了相同的错误。我发现pysnmpSE没有vv模块。我被建议如果使用pySNMP SE 3.x,则应解决跟随错误。

Traceback (most recent call last):
  File "C:\Documents and Settings\ggne0622\Desktop\Python\google-python-exercises\babynames\SimpleAgent.py", line 18, in <module>
    from twistedsnmp import agent, agentprotocol, bisectoidstore
  File "C:\Python27\Lib\site-packages\twistedsnmp\agent.py", line 4, in <module>
    from twistedsnmp import datatypes
  File "C:\Python27\Lib\site-packages\twistedsnmp\datatypes.py", line 7, in <module>
    from twistedsnmp.pysnmpproto import v2c,v1
  File "C:\Python27\Lib\site-packages\twistedsnmp\pysnmpproto.py", line 13, in <module>
    from pysnmp.v4.proto.omni import v2c,v1, error, rfc1157, rfc1905
ImportError: No module named v4.proto.omni

代码:

#!/usr/bin/env python
from twisted.internet.iocpreactor import reactor
from twisted.internet import error as twisted_error
from twistedsnmp import agent, agentprotocol, bisectoidstore
#from twisted.internet import interfaces
try:
    from twistedsnmp import bsdoidstore
except ImportError:
    import warnings
    warnings.warn( """No BSDDB OID Storage available for testing""" )
    bsdoidstore = None

def createAgent( oids ):
    ports = [161]+range(20000,25000)
    for port in ports:
        try:

        `agentObject = reactor.IOCPReactor.listenUDP(port,`   `agentprotocol.AgentProtocol(snmpVersion = 'v2c',agent = agent.Agent(dataStore =`   `bisectoidstore.BisectOIDStore(OIDs = oids,),),),)`  
    `except twisted_error.CannotListenError:`  
        `pass`  
    `else:`  
        `return agentObject, port`  

testingOIDs = {
    '.1.3.6.1.2.1.1.1.0': 'Some tool out in the field',
    '.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1',
    '.1.3.6.1.2.1.1.3.0': 558566090,
    '.1.3.6.1.2.1.1.4.0': "support@somewhere.ca",
    '.1.3.6.1.2.1.1.5.0': "NameOfSystem",
    '.1.3.6.1.2.1.1.6.0': "SomeHeadEnd, West Hinterlands, Canada",
}

def main(oids=testingOIDs):
    agent, port = createAgent( oids )

if __name__ == "__main__":
    reactor.IOCPReactor.callWhenRunning( main )
    reactor.IOCPReactor.run()

1 个答案:

答案 0 :(得分:0)

TwistedSNMP似乎不适用于PySNMP 4.x.因此,您应该使用PySNMP 3.x / PySNMP SE或切换到具有自己的Twisted绑定的PySNMP 4.x。