gpt4 book ai didi

python-2.7 - PYSNMP : TypeError: setComponentByType() got multiple values for keyword argument 'verifyConstraints'

转载 作者:行者123 更新时间:2023-12-04 00:10:52 24 4
gpt4 key购买 nike

面临 PYSNMP 4.3.3 的新问题。 Python 2.7.13。使用 SNMP GET 和 Getnext:Pysnmp 4.3.2 也可以正常工作。实际上,当它涉及虚拟环境时,我正在观察这个问题。在虚拟环境中,即使我将 Pysnmp 从 4.3.3 降级到 4.3.2,问题也会重现。

有人可以告诉我我缺少什么吗?

类型错误:setComponentByType() 获得关键字参数“verifyConstraints”的多个值

>>> from pysnmp.hlapi import *
>>> errorIndication, errorStatus, errorIndex, varBinds = next(
... getCmd(SnmpEngine(),
... CommunityData('public'),
... UdpTransportTarget(('127.0.0.1', 161)),
... ContextData(),
... ObjectType(ObjectIdentity('SNMPv2-MIB','sysDescr', 0)))
... )
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
File "/home/sourav/MyWorkSpace/tempproject_1/lib/python2.7/site-packages/pysnmp/hlapi/asyncore/sync/cmdgen.py", line 111, in getCmd
lookupMib=options.get('lookupMib', True)))
File "/home/sourav/MyWorkSpace/tempproject_1/lib/python2.7/site-packages/pysnmp/hlapi/asyncore/cmdgen.py", line 131, in getCmd
options.get('cbFun'), options.get('cbCtx'))
File "/home/sourav/MyWorkSpace/tempproject_1/lib/python2.7/site-packages/pysnmp/entity/rfc3413/cmdgen.py", line 214, in sendVarBinds
v2c.apiPDU.setVarBinds(reqPDU, varBinds)
File "/home/sourav/MyWorkSpace/tempproject_1/lib/python2.7/site-packages/pysnmp/proto/api/v1.py", line 136, in setVarBinds
varBindList.getComponentByPosition(idx), varBind
File "/home/sourav/MyWorkSpace/tempproject_1/lib/python2.7/site-packages/pysnmp/proto/api/v1.py", line 43, in setOIDVal
verifyConstraints=False)
TypeError: setComponentByType() got multiple values for keyword argument 'verifyConstraints'
>>>

与旧式也一样:

>>> from pysnmp.entity.rfc3413.oneliner import cmdgen
>>> cmdGen = cmdgen.CommandGenerator()
>>> errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(cmdgen.CommunityData('public'),cmdgen.UdpTransportTarget(('127.0.0.1', 161), timeout=60, retries=3),cmdgen.MibVariable('SNMPv2-MIB','sysDescr',0))

在下面的链接中,请引用最后两条评论。 https://github.com/home-assistant/home-assistant/issues/5790

使用的包:

appdirs==1.4.2
packaging==16.8
ply==3.10
pyasn1==0.2.3
pycryptodome==3.4.5
pyparsing==2.1.10
pysmi==0.0.7
pysnmp==4.3.3
six==1.10.0

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++更新:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++将 Pyasn1 从 pyasn1==0.2.3 降级到 0.1.9 后,代码似乎正常工作。但问题是,当全新安装 Pysnmp 4.3.3 时,它会采用 Pyasn1==0.2.3 并且失败。

最佳答案

这是 pyasn1/pysnmp 交互中的一个不幸的回归。

您可以通过将 pyasn1 降级到 0.2.2 或从 git master 获取 pysnmp 来解决此问题或者稍等一下,直到修复的 pysnmp 出来。

关于python-2.7 - PYSNMP : TypeError: setComponentByType() got multiple values for keyword argument 'verifyConstraints' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42514292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com