【问题标题】:Centos 7 and netsnmp for python 3用于 python 3 的 Centos 7 和 netsnmp
【发布时间】:2020-08-10 23:21:18
【问题描述】:

我在 centos 7 上安装了 python3,因为我应该开始将我的脚本从 python 2 移动到 3。

yum install python3

# rpm -qa |grep python3
python3-libs-3.6.8-13.el7.x86_64
python3-setuptools-39.2.0-10.el7.noarch
python3-pip-9.0.3-7.el7_7.noarch
python3-3.6.8-13.el7.x86_64

我有一个脚本可以导入 netsnmp 并使用它。在 python 2 下可以正常工作,但在 python 3 下不行。

# rpm -qa |grep python |grep -i snmp
net-snmp-python-5.7.2-48.el7_8.1.x86_64

在python3下我得到这个错误:

Traceback (most recent call last):
  File "up.py", line 52, in <module>
    oid = netsnmp.Varbind('.1.3.6.1.2.1.1.5.0')
AttributeError: module 'netsnmp' has no attribute 'Varbind'

有没有一种方法可以让 netsnmp 在 centos 7 下与 python 3 一起工作,并且无需大惊小怪且不会破坏任何东西?

【问题讨论】:

  • 我更新了描述我得到的错误。感谢您指出这一点。
  • 你完成python3 -m pip install python3-netsnmp了吗?你可以做import netsnmp,然后print(dir(snmp)) 看看有哪些属性/功能可用......但Varbind 确实存在
  • >>> print(dir(netsnmp)) ['doc', 'loader', 'name '、''、'路径'、'规范']

标签: python centos snmp


【解决方案1】:

快跑吧。

yum install python2 -y

然后

yum install python36 -y

它应该可以工作,因为它覆盖或更新了所需的依赖项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-22
    • 2020-04-02
    • 2022-01-04
    • 1970-01-01
    • 1970-01-01
    • 2015-12-11
    • 1970-01-01
    相关资源
    最近更新 更多