Centos 7和用于Python 3的netsnmp

问题描述

我在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下工作?

解决方法

只要跑步。

yum install python2 -y

然后

yum install python36 -y

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...