我得到這個錯誤fatal error: net-snmp/net-snmp-config.h: No such file or directory
。我已經安裝了gcc, python-devel, net-snmp, net-snmp-utils, net-snmp-python
和其他開發依賴項。在centos上安裝python netsnmp 7
CentOS Linux release 7.1.1503 (Core)
[[email protected] python]$ wget http://sourceforge.net/projects/net-snmp/files/net-snmp/5.5.2/net-snmp-5.5.2.tar.gz
[[email protected] python]$ pwd
/tmp/net-snmp-5.5.2/python
[[email protected] 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
[[email protected] python]$
UPDATE1:在netsnmp源代碼目錄運行./configure && make && make install
後,我能夠運行python setup.py install
。不過,現在我從蟒蛇收到此錯誤:
>>> 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:我的壞!我從netsnmp源代碼目錄中運行python解釋器dir cd /tmp/net-snmp-master/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()
UPDATE3
[[email protected] ~]# sudo ldconfig
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]#
UPDATE4:最後通過運行sudo ldconfig
和修改/etc/ld.so.conf.d/libc.conf
[[email protected] ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
[[email protected] ~]# cat > /etc/ld.so.conf.d/libc.conf <<EOF
> /usr/local/lib
> EOF
[[email protected] ~]# ldconfig
[[email protected] ~]# python
>>> import netsnmp
>>> exit()
[[email protected] ~]#
我剛剛做了'yum install net-snmp-devel'。但即使在那之前,我實際上已經能夠通過第一次運行'./configure;來安裝python綁定了。使;從netsnmp來源安裝'。然而,我現在得到以下錯誤:'ImportError:No module named client_intf' when I try nenting netsnmp – abarik
更新了問題 – abarik
我不明白'net-snmp-python'的用法是什麼?我沒有看到任何正在安裝的python軟件包 – abarik