I am getting this error fatal error: net-snmp/net-snmp-config.h: No such file or directory
. I have installed gcc, python-devel, net-snmp, net-snmp-utils, net-snmp-python
and other development dependencies.
CentOS Linux release 7.1.1503 (Core)
[admin@localhost python]$ wget http://sourceforge.net/projects/net-snmp/files/net-snmp/5.5.2/net-snmp-5.5.2.tar.gz
[admin@localhost python]$ pwd
/tmp/net-snmp-5.5.2/python
[admin@localhost python]$ python setup.py build
sh: net-snmp-config: command not found
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/netsnmp
copying netsnmp/__init__.py -> build/lib.linux-x86_64-2.7/netsnmp
copying netsnmp/client.py -> build/lib.linux-x86_64-2.7/netsnmp
creating build/lib.linux-x86_64-2.7/netsnmp/tests
copying netsnmp/tests/__init__.py -> build/lib.linux-x86_64-2.7/netsnmp/tests
copying netsnmp/tests/test.py -> build/lib.linux-x86_64-2.7/netsnmp/tests
running build_ext
building 'netsnmp.client_intf' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/netsnmp
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/admin/miniconda/envs/py_env_clink/include/python2.7 -c netsnmp/client_intf.c -o build/temp.linux-x86_64-2.7/netsnmp/client_intf.o
netsnmp/client_intf.c:9:38: fatal error: net-snmp/net-snmp-config.h: No such file or directory
#include <net-snmp/net-snmp-config.h>
compilation terminated.
error: command 'gcc' failed with exit status 1
[admin@localhost python]$
UPDATE1: After running ./configure && make && make install
on the netsnmp source dir, I was able to run python setup.py install
. However, now I am getting this error from python:
>>> import netsnmp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "netsnmp/__init__.py", line 1, in <module>
from client import *
File "netsnmp/client.py", line 1, in <module>
import client_intf
ImportError: No module named client_intf
>>>
UPDATE2: My bad!! I was running python interpreter from the directory of netsnmp source dir cd /tmp/net-snmp-master/python/
which was causing me to give the expected error as python was not using the import from the egg, but from the source. Anyways, after doing a cd ~
, I am getting a new error
>>> import netsnmp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/__init__.py", line 1, in <module>
#
File "build/bdist.linux-x86_64/egg/netsnmp/client.py", line 1, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/client_intf.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/client_intf.py", line 6, in __bootstrap__
ImportError: libnetsnmp.so.30: cannot open shared object file: No such file or directory
>>> exit()
UPDATE3
[root@localhost ~]# sudo ldconfig
[root@localhost ~]# sudo ldconfig -p | grep netsnmp
libnetsnmptrapd.so.31 (libc6,x86-64) => /lib64/libnetsnmptrapd.so.31
libnetsnmptrapd.so (libc6,x86-64) => /lib64/libnetsnmptrapd.so
libnetsnmpmibs.so.31 (libc6,x86-64) => /lib64/libnetsnmpmibs.so.31
libnetsnmpmibs.so (libc6,x86-64) => /lib64/libnetsnmpmibs.so
libnetsnmphelpers.so.31 (libc6,x86-64) => /lib64/libnetsnmphelpers.so.31
libnetsnmphelpers.so (libc6,x86-64) => /lib64/libnetsnmphelpers.so
libnetsnmpagent.so.31 (libc6,x86-64) => /lib64/libnetsnmpagent.so.31
libnetsnmpagent.so (libc6,x86-64) => /lib64/libnetsnmpagent.so
libnetsnmp.so.31 (libc6,x86-64) => /lib64/libnetsnmp.so.31
libnetsnmp.so (libc6,x86-64) => /lib64/libnetsnmp.so
[root@localhost ~]# find / -name libnetsnmp.so*
find: ‘/run/user/1000/gvfs’: Permission denied
/usr/lib64/libnetsnmp.so
/usr/lib64/libnetsnmp.so.31
/usr/lib64/libnetsnmp.so.31.0.2
/usr/local/lib/libnetsnmp.so.30.0.3
/usr/local/lib/libnetsnmp.so.30.0.1
/usr/local/lib/libnetsnmp.so
/usr/local/lib/libnetsnmp.so.30
[root@localhost ~]#
UPDATE4: Finally fixed the problem by running sudo ldconfig
and modifying /etc/ld.so.conf.d/libc.conf
[root@localhost ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
[root@localhost ~]# cat > /etc/ld.so.conf.d/libc.conf <<EOF
> /usr/local/lib
> EOF
[root@localhost ~]# ldconfig
[root@localhost ~]# python
>>> import netsnmp
>>> exit()
[root@localhost ~]#
Make sure you have installed net-snmp-devel. Check the existing of /usr/include/net-snmp/net-snmp-config.h