在centos 7上安装python netsnmp

在centos 7上安装python netsnmp,python,net-snmp,Python,Net Snmp,我收到这个错误致命错误:net snmp/net snmp config.h:没有这样的文件或目录。我已经安装了gcc、python-devel、net-snmp、net-snmp-utils、net-snmp-python和其他开发依赖项 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/net snmp config.h:没有这样的文件或目录
。我已经安装了
gcc、python-devel、net-snmp、net-snmp-utils、net-snmp-python
和其他开发依赖项

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]$
更新2:我的坏!!我在netsnmp source dir
cd/tmp/net snmp master/python/
目录下运行python解释器,这导致我给出了预期的错误,因为python使用的不是来自egg的导入,而是来自源代码的导入。无论如何,在做了
cd~
之后,我得到了一个新的错误

>>> 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()
UPDATE4:通过运行
sudo ldconfig
并修改
/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 ~]# 
[root@localhost~]#cat/etc/ld.so.conf
包括ld.so.conf.d/*.conf
[root@localhost~]#cat>/etc/ld.so.conf.d/libc.conf EOF
[root@localhost~]#ldconfig
[root@localhost~]#python
>>>导入netsnmp
>>>退出()
[root@localhost ~]# 

确保已安装net snmp devel。
检查现有的/usr/include/net snmp/net snmp config.h

我刚刚执行了
yum安装net snmp-devel
。但即使在那之前,我实际上至少能够通过第一次运行
/configure来构建和安装python绑定;制作从netsnmp源代码进行安装。但是,我现在遇到了以下错误:
ImportError:当我尝试导入netsnmpI时,没有名为client\u intf的模块不理解
net snmp python
??我没有看到任何python软件包正在安装。您是否尝试过python setup.py安装?此外,在构建之后,您可以在net-snmp-5.5.2/python/build/lib.linux-x86_64-2.7中找到netsnmp。是的,这正是我所做的
python setup.py安装
但是我得到了客户机intf的importorror
oops…,我再次更新了这个问题。。。让我试试ldconfig,但用什么?
[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 ~]# 
[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 ~]#