ctypes find_library没有咨询LD_LIBRARY_PATH?

时间:2015-08-31 10:59:21

标签: python ctypes

我正在尝试在Linux上使用基于ctypes的{​​{1}}包装器,它安装在非标准路径中。但是:

librsync
之前已经设置了

----> 1 import librsync /home/ptest/lib/python2.7/site-packages/librsync/__init__.py in <module>() 11 path = ctypes.util.find_library('rsync') 12 if path is None: ---> 13 raise ImportError('Could not find librsync, make sure it is installed') 14 try: 15 _librsync = ctypes.cdll.LoadLibrary(path) ImportError: Could not find librsync, make sure it is installed ,但LD_LIBRARY_PATH似乎并不尊重它。搜索提出了沿着这条线提出的许多问题,但我似乎无法找到解决方案。有什么帮助吗?

2 个答案:

答案 0 :(得分:0)

从Python 3.6开始,it does

对于早期版本,@eryksun suggested此替代方法:

os.environ['LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']

答案 1 :(得分:-1)

之前这样做:

sudo apt-get install librsync-dev