ImportError:没有名为netsnmp的模块

时间:2017-04-03 20:51:14

标签: python linux

我得到一个" ImportError:没有名为netsnmp的模块"我尝试运行python脚本时的消息。有人可以帮帮我吗?我没有任何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]# 

1 个答案:

答案 0 :(得分:1)

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

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

sudo apt-get install net-snmp-python

检查你是否有嘘声 使用,pip install <pynetsnmp> // missing pacakage name

Detailed information about installing missing python packages.