未定义会话

发布于 2024-10-06 05:44:22 字数 1833 浏览 1 评论 0原文

我正在尝试运行此示例程序 - 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感情洁癖 2024-10-13 05:44:22

您安装了哪个版本的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 of pysnmp.

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.

梨涡 2024-10-13 05:44:22

pyasn1 已被 pysnmp 依赖。所以你只需输入:

from pyasn1.error import PyAsn1Error 

pyasn1 has been depended by pysnmp. So you could just type:

from pyasn1.error import PyAsn1Error 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文