我通过pip install extractor
使用python2.7中的extractor
模块。我在使用自制程序的OSX上,我以前运行过homebrew install libextractor
。这将在/usr/local/lib中创建扩展名为.a和.dylib的文件。(GNU-libextractor)
第36行附近提取器.py,代码如下:
try: #loading shared object file libextractor = cdll.LoadLibrary('libextractor.so.3') except OSError: libextractor = cdll.extractor
当我试图从python shell中OSError: dlopen(extractor, 6): image not found
时,我得到了OSError: dlopen(extractor, 6): image not found
。在
这似乎是因为我没有.so.3文件,它是在模块中硬编码的。但是错误来自except块,而不是try块。在
这个错误是由于libextractor.so.3,如果是这样,我如何告诉python加载正确的库?我尝试过用各种文件(.a,.dylib)替换该值,但没有成功。在
您是否尝试过遵循以下说明:
http://www.gnu.org/software/libextractor/manual/html_node/Preparation.html
如果有效,你应该使用ctype.CDLL(“libextractor”)并让ctypes找出正确的扩展名。遗憾的是,操作系统特有的扩展魔法并不存在。在
{{cd2}提供的方法有效。可悲的是,它依赖于外部程序,这意味着在小型或怪异的系统上运行时会被破坏。在
other projects went ahead and hardcoded extension基于操作系统(). 如果必要的话就这么做。在
p.S.except子句是一些奇怪的解决方法,实际上}或扩展的{}相同。在
ctypes.cdll.foo
相当于ctypes.cdll.__getattr__("foo")
,它与没有{相关问题 更多 >
编程相关推荐