未定义会话
我正在尝试运行此示例程序 - http://pysnmp.sourceforge.net/ example/1.x/snmpbulk.html
我在 Mac OS X 上,我安装了 pysnmp -
$ sudo /usr/local/bin/pip install pysnmp
现在,当我运行该程序时,我得到 -
Traceback (most recent call last):
File "pysnmptest.py", line 2, in <module>
from pysnmp import msession
ImportError: cannot import name msession
更新:
似乎 pysnmp 4.x 没有 msession,所以我尝试了 http://pysnmp.sourceforge.net/examples/4.x /v3arch/index.html
现在我明白了 -
Traceback (most recent call last):
File "pysnmptest.py", line 2, in <module>
from pysnmp.entity.rfc3413.oneliner import cmdgen
File "/Library/Python/2.6/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 2, in <module>
from pysnmp.entity import engine, config
File "/Library/Python/2.6/site-packages/pysnmp/entity/engine.py", line 2, in <module>
from pysnmp.proto.rfc3412 import MsgAndPduDispatcher
File "/Library/Python/2.6/site-packages/pysnmp/proto/rfc3412.py", line 3, in <module>
from pysnmp.smi import builder, instrum
File "/Library/Python/2.6/site-packages/pysnmp/smi/builder.py", line 4, in <module>
from pysnmp.smi import error
File "/Library/Python/2.6/site-packages/pysnmp/smi/error.py", line 1, in <module>
from pyasn1.error import PyAsn1Error
ImportError: No module named pyasn1.error
该网页还说它们依赖于第三方库 -
最新 PySNMP 版本(4.x 及更高版本) 取决于以下因素:
Python 的 ASN.1 库用于 处理 ASN.1 对象 Python
用于 SNMP 的加密工具包 消息认证和加密
如何安装它们?直接从网页的 tarball 安装会更好吗?
I am trying to run this example program - http://pysnmp.sourceforge.net/examples/1.x/snmpbulk.html
I am on Mac OS X, and I installed pysnmp by -
$ sudo /usr/local/bin/pip install pysnmp
Now when I run the program I get -
Traceback (most recent call last):
File "pysnmptest.py", line 2, in <module>
from pysnmp import msession
ImportError: cannot import name msession
UPDATE:
seems like pysnmp 4.x doesn't have msession, so I tried http://pysnmp.sourceforge.net/examples/4.x/v3arch/index.html
and now I get -
Traceback (most recent call last):
File "pysnmptest.py", line 2, in <module>
from pysnmp.entity.rfc3413.oneliner import cmdgen
File "/Library/Python/2.6/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 2, in <module>
from pysnmp.entity import engine, config
File "/Library/Python/2.6/site-packages/pysnmp/entity/engine.py", line 2, in <module>
from pysnmp.proto.rfc3412 import MsgAndPduDispatcher
File "/Library/Python/2.6/site-packages/pysnmp/proto/rfc3412.py", line 3, in <module>
from pysnmp.smi import builder, instrum
File "/Library/Python/2.6/site-packages/pysnmp/smi/builder.py", line 4, in <module>
from pysnmp.smi import error
File "/Library/Python/2.6/site-packages/pysnmp/smi/error.py", line 1, in <module>
from pyasn1.error import PyAsn1Error
ImportError: No module named pyasn1.error
The webpage also says they have dependencies on third-party libraries -
Latest PySNMP releases (4.x and later)
depend on the following:ASN.1 library for Python used for
handling ASN.1 objects Python
Cryptography Toolkit used for SNMP
message authentication and encryption
How do I install them? and would it better to install from the tarball from webpage directly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您安装了哪个版本的
pysmnp
?您尝试运行的示例似乎适合 1.x 版本的pysnmp
。在这里我找到了最新 4的示例.x 版本。请注意,他们不使用
msession
所以我猜它已被删除。编辑:看起来现在您必须从此处安装
pyasn1
一个>...我不使用 OSX,所以我不知道在 OSX 上安装软件的更好方法是什么。在 ubuntu 上,我刚刚做了 apt-get install python-pysnmp ,整个东西就安装好了。
which version of
pysmnp
did you install? The example you're trying to run seems to be suited for the 1.x version ofpysnmp
.Here I've found examples for the newest 4.x version. Note they don't use
msession
so I guess it was removed.EDIT: Looks like now you have to install
pyasn1
from here...I don't use OSX so I don't know what's the better method for installing software on it. On ubuntu I just did
apt-get install python-pysnmp
and the whole thing was installed.pyasn1
已被 pysnmp 依赖。所以你只需输入:pyasn1
has been depended by pysnmp. So you could just type: