gpt4 book ai didi

python - 导入错误: No module named netsnmp

转载 作者:太空宇宙 更新时间:2023-11-04 04:44:50 25 4
gpt4 key购买 nike

当我尝试运行 python 脚本时,收到“ImportError:没有名为 netsnmp 的模块”消息。有人可以帮我吗?我没有任何 python 脚本编写经验。

这是我想使用的 Icinga 插件脚本。但我无法让它在我的 Icinga 服务器上运行。 Icinga 服务器是 Red Hat Linux,并且是在我之前配置的。任何帮助将非常感激。下面是错误的屏幕截图。

[icinga@USDCPVAS054 ~]$ /usr/bin/check_snmp_idrac.py -h
Traceback (most recent call last):
File "/usr/bin/check_snmp_idrac.py", line 5, in <module>
pkg_resources.run_script('health-monitoring-plugins==0.0.5', 'check_snmp_idrac.py')
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 461, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1194, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/lib/python2.6/site-packages/health_monitoring_plugins-0.0.5-py2.6.egg/EGG-INFO/scripts/check_snmp_idrac.py", line 20, in <module>
import netsnmp
ImportError: No module named netsnmp
[icinga@USDCPVAS054 ~]$

预先感谢您的帮助

<小时/>

感谢您的帮助。我尝试安装 netsnmp-py3-0.3 python 包,但收到错误。对下面的错误有什么想法吗?谢谢

    [root@USDCPVAS054 netsnmp-py3-0.3]# python setup.py install
running install
running bdist_egg
running egg_info
writing netsnmp_py.egg-info/PKG-INFO
writing top-level names to netsnmp_py.egg-info/top_level.txt
writing dependency_links to netsnmp_py.egg-info/dependency_links.txt
reading manifest file 'netsnmp_py.egg-info/SOURCES.txt'
writing manifest file 'netsnmp_py.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
building 'netsnmp._api' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURC E -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC - fwrapv -fPIC -I./netsnmp -I/usr/include/python2.6 -c netsnmp/session.c -o build/temp.linux-x86_64-2.6/netsnmp/session.o
netsnmp/session.c:1:20: error: Python.h: No such file or directory
In file included from netsnmp/session.c:2:
./netsnmp/_api.h:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
./netsnmp/_api.h:19: error: expected ‘)’ before ‘*’ token
./netsnmp/_api.h:20: error: expected ‘)’ before ‘*’ token
./netsnmp/_api.h:21: error: expected ‘)’ before ‘*’ token
./netsnmp/_api.h:22: error: expected ‘)’ before ‘*’ token
./netsnmp/_api.h:27: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
./netsnmp/_api.h:28: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
./netsnmp/_api.h:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
./netsnmp/_api.h:36: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
./netsnmp/_api.h:39: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
netsnmp/session.c:5:40: error: net-snmp/net-snmp-features.h: No such file or directory
netsnmp/session.c:8: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
netsnmp/session.c:60: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
error: command 'gcc' failed with exit status 1
[root@USDCPVAS054 netsnmp-py3-0.3]#

最佳答案

您需要做的是安装缺少的软件包。

如果你没有Python设置工具我建议你这样做,sudo apt-get install python-setuptools ,安装缺少的包。

sudo apt-get install net-snmp-python

检查您是否有 snmpt使用,pip install <pynetsnmp> // missing pacakage name

Detailed information about installing missing python packages.

关于python - 导入错误: No module named netsnmp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43194032/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com