Alex
Alex

Reputation: 11

ImportError: No module named netsnmp

I am get an "ImportError: No module named netsnmp" message when I try to run a python script. Can some please help me? I do not have any python scripting experience.

This is a plugin script for Icinga that I would like to use. I am unable to get it to run on my Icinga server though. The Icinga server is Red Hat Linux and was configured before my time. Any help would be much appreciated. Below is a screen shot of the error.

[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 ~]$

Thanks in advance for your help


Thanks for your help. I tried installing the netsnmp-py3-0.3 python package but I received an error. Any ideas on the error below? Thanks

    [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]# 

Upvotes: 0

Views: 7658

Answers (1)

danglingpointer
danglingpointer

Reputation: 4920

What you need to do is to install the missing package.

If you didnt have python setup tool I suggest you to do it, sudo apt-get install python-setuptools, install missing package.

or

sudo apt-get install net-snmp-python

check you have snmpt use, pip install <pynetsnmp> // missing pacakage name

Detailed information about installing missing python packages.

Upvotes: 2

Related Questions