When I try to import darknet to use in a separate python program, I get the error in the title.
I am using OpenCV3.4.0, and compile darknet with options:
GPU=0
CUDNN=0
CUDNN_HALF=0
OPENCV=1
AVX=1
OPENMP=1
LIBSO=1
I have made sure that darknet.py is on the path:
import sys
darknet_path='/path/to/AlexeyAB_darknet'
sys.path.append(darknet_path)
This stackoverflow page suggests I might be missing an init file, or the init file might not have the correct naming conventions. One answer also suggests that I should try using a different python version. My default python version is 2.7. If I try python3, I get a different, but similar error:
ImportError: dynamic module does not define module export function (PyInit_darknet)
Am I doing something wrong, is this intended behaviour, or is there an issue with darknet?
I had trouble until ran it from the directory that had darknet.so in it. Adding it to the path wasn't enough. I don't know why and as soon as I got it working, I didn't investigate further. I am using python3.
Thanks for the quick suggestion. I was running it from that directory when I tried the python3 example at the end of my post.
I ended up needing two changes to make this work.
darknet_so.so) and updating the references to the so in darknet.pyAs a postscript: if you give the absolute path to darknet_so.so in darknet.py, you don't need to run it in the darknet directory (or link any files).
Most helpful comment
I ended up needing two changes to make this work.
darknet_so.so) and updating the references to the so indarknet.py