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

它应该工作,因为它涵盖或更新了所需的依赖关系。

最新更新