here is my python package's __init__.py file
# mypackage/__init__.py
import ctypes
def init_lib():
print("init_lib")
lib = ctypes.CDLL("libcilin_similarity.dylib")
lib.read_cilin('cilin.txt'.encode('UTF-8'))
lib.similarity.restype = ctypes.c_float
return lib
def compare(lib, first_word, second_word):
print("this should work")
print(second_word, lib.similarity(first_word.encode('UTF-8'), second_word.encode('UTF-8')))
If I'm running the __init__.py directly, it works pretty fine.
But if I'm trying to import the package from outside, it keeps giving me the OSError error:
OSError: dlopen(libcilin_similarity.dylib, 6): image not found
Could anyone help me prevent this error from happening? Many thanks!
the directory structure is
cilin_similarity
|- __init__.py
|- libcilin_similarity.dylib
try.py # <- where I tried to import the package, but failed
And when I try using absolute path, it gave me Error opening file
error...