0
我使用python 2.7.8。
我這個代碼轉換成一個EXE使用py2exe:py2exe不能與pysnmp 4.3.0一起使用
from pysnmp.hlapi.asyncore import *
def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx):
print(errorIndication, errorStatus, errorIndex, varBinds)
snmpEngine = SnmpEngine()
getCmd(snmpEngine,
CommunityData('public'),
UdpTransportTarget(('demo.snmplabs.com', 161)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
cbFun=cbFun)
snmpEngine.transportDispatcher.runDispatcher()
但每次我運行exe我碰到下面的錯誤時間:
could not get source code
Traceback (most recent call last):
File "Maprinter.py", line 11, in <module>
File "pysnmp\entity\rfc3413\oneliner\cmdgen.pyc", line 124, in nextCmd
File "pysnmp\hlapi\asyncore\cmdgen.pyc", line 337, in nextCmd
File "pysnmp\hlapi\varbinds.pyc", line 30, in makeVarBinds
File "pysnmp\smi\rfc1902.pyc", line 707, in resolveWithMib
File "pysnmp\smi\rfc1902.pyc", line 302, in resolveWithMib
File "pysnmp\smi\compiler.pyc", line 42, in addMibCompiler
File "pysmi\parser\smi.pyc", line 21, in __init__
File "pysmi\lexer\smi.pyc", line 83, in __init__
File "pysmi\lexer\smi.pyc", line 100, in reset
File "ply\lex.pyc", line 906, in lex
File "ply\lex.pyc", line 580, in validate_all
File "ply\lex.pyc", line 822, in validate_rules
File "ply\lex.pyc", line 833, in validate_module
File "inspect.pyc", line 690, in getsourcelines
File "inspect.pyc", line 538, in findsource
IOError: could not get source code
我應該怎麼做得太解決這個問題呢?