DLL load failed when importing a self-built cv2 library in python

Process monitor is the only tool you need for this error and its ouput is giving you the correct information. The error implies you didn’t build the opencv_videoio module successfully which is why your getting the error.

When you build the INSTALL target without errors you will have a cv2 folder inside your site-packages directory containg the .pyd so you will need to delete the one you manually copied for everything to work correctly.

Once that is working, if you still have problems then use Process Monitor again. If there are too many entries, export the log File->Save (Comma-Separated Values) and parse it manually e.g.


import csv
from pathlib import Path
import re
def print_missing_libs(process_mon_export_file_path):
    shared_libs = {}
    with open(process_mon_export_file_path, mode='r') as file:
        for row in csv_reader:
            key = Path(row[3]).name
            val = row[4]
            if (key not in shared_libs or key in shared_libs and shared_libs[key] != 'SUCCESS'):
                shared_libs[key] = val
    
    pattern = re.compile(r"__init__")
    for entry, status in shared_libs.items():
        if(status == 'NAME NOT FOUND' and not re.search(pattern, entry)):
            print(entry)

print_missing_libs(Logfile.CSV)

Then deal with the non windows dll’s (nvidia, gstreamer) first as they can be false positives.

1 Like