ImportError: DLL load failed while importing cv2: The specified module could not be found

Just want to share that I was able to resolve this problem yesterday. Found the culprit DLL: it’s the HDF5 which I installed last Jan 1. My first source compilation was Dec 29 that’s why it worked the first time. So basically, the fix was:

  • After installation, edit cv2/ and add the path to my hdf5.dll. Again, I’m using OpenCV 4.5.1 source.

This was a good and painful learning experience for me. I was able to rebuild it again and add support for CUDA too.

1 Like

Thanks for this tip, it helped me a lot. But in OpenCV 4.5.1, I think it’s best to add the directories in cv2/ so that other codes will just include import cv2 only.

Got it. I guess we just indeed have to rely on Dependency Walker for now.

When I use python, I also get an error “C:\DevHome\Program\OpenCV450\build\python_loader\”. Just use “pip uninstall opencv-python” and reinstall it.
Record it.As a non-native English speaker, it is too difficult to find information and solve problems :dizzy_face:

In my case this simple thing solved the error: import numpy before import cv2…