关于python导入模块失败的问题

BrankoJuan 发布于 2016/05/25 21:41
阅读 688
收藏 0

1.下载netsnmp的源码包, net-snmp-5.7.3.zip

2.解压并安装,tar xzvf net-snmp-5.7.3.zip; cd net-snmp-5.7.3; ./configure; make ; make install 安装成功

3.安装python的snmp库,cd net-snmp-5.7.3/python; /home/kan/python/bin/python setup.py install 安装成功

4.安装成功之后, 运行pythonshell,发现导入失败,/home/kan/python/bin/python

Python 2.7.10 (default, Aug 15 2015, 14:52:42) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 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
>>> 
我find的一下libnetsnmp.so.30,发现这个库是存在的,在/usr/local/lib下

cd /

[root@192 /]# find ./ -name "libnetsnmp.so.30"
./usr/local/lib/libnetsnmp.so.30

导入netsnmp的时候,涉及到的egg是'/home/kan/python/lib/python2.7/site-packages/netsnmp_python-1.0a1-py2.7-linux-x86_64.egg'

问题:

1.我需要如何才能将/usr/local/lib/libnetsnmp.so.30
'/home/kan/python/lib/python2.7/site-packages/netsnmp_python-1.0a1-py2.7-linux-x86_64.egg'联系起来,令python在导入netsnmp的时候能找到libnetsnmp.so.30?

加载中
0
B
BrankoJuan

明白了了,是我编译python的netsnmp的时候没有指定库

echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
/home/kan/python/bin/python setup.py install

编译完后即可

返回顶部
顶部