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

I’m hoping someone can guide me resolve this error on my setup. Note that I did not encounter this error on my first try of building the code (used OPENCV_ENABLE_NONFREE). After a while (couple of days), I then tried to include CUDA but this error starts to appear:

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\DevHome\Program\OpenCV450\build\python_loader\cv2\__init__.py", line 96, in <module>
    bootstrap()
  File "C:\DevHome\Program\OpenCV450\build\python_loader\cv2\__init__.py", line 86, in bootstrap
    import cv2
ImportError: DLL load failed while importing cv2: The specified module could not be found.

After several days of trying and searching the net, I’m still unable to find a solution. I did try reinstalling Python (still 3.8.6) and changed OpenCV version to 4.5.0 (from 4.5.1) but still no luck. Perhaps a Windows or driver update caused the problem? My recent finding is that when I don’t include OPENCV_ENABLE_NONFREE, the error is gone (but why was I successful before?)

Here are the details of my setup:
– CMake

Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
Detected processor: AMD64
libjpeg-turbo: VERSION = 2.0.5, BUILD = opencv-4.5.0-libjpeg-turbo
Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
OpenJPEG: VERSION = 2.3.1, BUILD = opencv-4.5.0-openjp2-2.3.1
OpenJPEG libraries will be built from sources: libopenjp2 (version "2.3.1")
found Intel IPP (ICV version): 2020.0.0 [2020.0.0 Gold]
at: C:/DevHome/Program/OpenCV450/build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2020.0.0
at: C:/DevHome/Program/OpenCV450/build/3rdparty/ippicv/ippicv_win/iw
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find BLAS (missing: BLAS_LIBRARIES) 
Could NOT find LAPACK (missing: LAPACK_LIBRARIES) 
    Reason given by package: LAPACK could not be found because dependency BLAS could not be found.

VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
OpenCV Python: during development append to PYTHONPATH: C:/DevHome/Program/OpenCV450/build/python_loader
Module opencv_alphamat disabled because the following dependencies are not found: Eigen
Caffe:   NO
Protobuf:   NO
Glog:   NO
freetype2:   NO
harfbuzz:    NO
Julia not found. Not compiling Julia Bindings. 
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
Allocator metrics storage type: 'long long'
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': C:/DevHome/Program/OpenCV450/source/opencv-4.5.0/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
opencv_dnn: filter out cuda4dnn source code

General configuration for OpenCV 4.5.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            C:/DevHome/Program/OpenCV450/source/opencv_contrib-4.5.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2021-01-14T11:59:53Z
    Host:                        Windows 10.0.19042 AMD64
    CMake:                       3.19.2
    CMake generator:             Visual Studio 16 2019
    CMake build tool:            C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
    MSVC:                        1928

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (17 files):         + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (31 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (7 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

  C/C++:
    Built as dynamic libs?:      YES
    C++ standard:                11
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe  (ver 19.28.29336.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MD /O2 /Ob2 /DNDEBUG  /Zi
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MDd /Zi /Ob0 /Od /RTC1 
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP   /MD /O2 /Ob2 /DNDEBUG  /Zi
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP /MDd /Zi /Ob0 /Od /RTC1 
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO  /debug
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL 
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 alphamat cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype java js julia matlab ovis python2 sfm viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         YES

  Windows RT support:            NO

  GUI: 
    Win32 UI:                    YES
    VTK support:                 NO

  Media I/O: 
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 2.0.5-62)
    WEBP:                        build (ver encoder: 0x020f)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.0.10)
    JPEG 2000:                   build (ver 2.3.1)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (58.91.100)
      avformat:                  YES (58.45.100)
      avutil:                    YES (56.51.100)
      swscale:                   YES (5.7.100)
      avresample:                YES (4.0.0)
    GStreamer:                   NO
    DirectShow:                  YES
    Media Foundation:            YES
      DXVA:                      YES

  Parallel framework:            Concurrency

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2020.0.0 Gold [2020.0.0]
           at:                   C:/DevHome/Program/OpenCV450/build/3rdparty/ippicv/ippicv_win/icv
    Intel IPP IW:                sources (2020.0.0)
              at:                C:/DevHome/Program/OpenCV450/build/3rdparty/ippicv/ippicv_win/iw
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  OpenCL:                        YES (NVD3D11)
    Include path:                C:/DevHome/Program/OpenCV450/source/opencv-4.5.0/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python 3:
    Interpreter:                 C:/DevHome/Program/Python/Python38/python.exe (ver 3.8.6)
    Libraries:                   optimized C:/DevHome/Program/Python/Python38/libs/python38.lib debug C:/DevHome/Program/Python/Python38/libs/python38_d.lib (ver 3.8.6)
    numpy:                       C:/DevHome/Program/Python/Python38/lib/site-packages/numpy/core/include (ver 1.19.3)
    install path:                C:/DevHome/Program/Python/Python38/Lib/site-packages/cv2/python-3.8

  Python (for build):            C:/DevHome/Program/Python/Python38/python.exe

  Java:                          
    ant:                         NO
    JNI:                         C:/Program Files/Java/jdk-11.0.9/include C:/Program Files/Java/jdk-11.0.9/include/win32 C:/Program Files/Java/jdk-11.0.9/include
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    C:/DevHome/Program/OpenCV450/build/install
-----------------------------------------------------------------

Configuring done

– Hardware

Let me know if you need other details. Note that VS 2019 compilation and installation are both successful.

Any kind of help will be highly appreciated.

Windows Environment
– Path

C:\Program Files\ImageMagick-7.0.10-Q16-HDRI
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\libnvvp
C:\Program Files\Common Files\Oracle\Java\javapath
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\nodejs\
C:\Program Files\Perforce\
C:\Program Files\Git\cmd
C:\Program Files\Docker\Docker\resources\bin
C:\ProgramData\DockerDesktop\version-bin
C:\Program Files\PuTTY\
C:\HDF5\1.12.0\bin\
C:\Program Files (x86)\Gpg4win\..\GnuPG\bin
C:\DevHome\Program\Python\Python38\Scripts\
C:\DevHome\Program\Python\Python38\
C:\Users\adimaunahan\AppData\Roaming\npm
C:\Users\adimaunahan\AppData\Local\Programs\Microsoft VS Code\bin
C:\Program Files\CMake\bin
C:\tesseract500
C:\poppler-20.12.1\Library\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin
C:\DevHome\CUDA\cudnn\lib\x64
C:\DevHome\Program\OpenCV450\build\bin\Release
C:\DevHome\Program\OpenCV450\build\lib\Release
C:\DevHome\Program\OpenCV450\build\install\x64\vc16\bin
C:\DevHome\Program\OpenCV450\build\modules
C:\DevHome\Program\OpenCV450\build\3rdparty\ffmpeg
C:\Users\adimaunahan\AppData\Local\Microsoft\WindowsApps

– PYTHONPATH

C:\DevHome\Program\OpenCV450\build\python_loader
C:\DevHome\Program\OpenCV450\build\bin\Release

Are you 100% that building without OPENCV_ENABLE_NONFREE always works or did it just work the first time?
If its that then I would assume one of the extra modules has a dependent dll.

Can you run the OpenCv test programs without issue, e.g. opencv_test_core.exe? As you are not building world you may need to make sure all the test programs work to see if you need a dll which isn’t on your path.

Which directory containing the opencv dll’s did you add to your path bin or install\x64\vc16\bin?

If the error occurred when you included CUDA, check you have the CUDA bin directory of the CUDA version you built against on your system/user path, e.g.

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\bin

Thanks for a quick response. I’ll try to run the OpenCV tests.

I did learn about Dependency walker tool and used it to the cv2.pyd output from the build. Every dll seems fine.

I have one question: is there a way to edit OpenCV’s code to tell me which specific DLL is being loaded and failing?

Just seen your extra reply.

You could also try

import os
os.add_dll_directory('C:\\DevHome\\Program\\OpenCV450\\build\\lib\\Release')

if that’s the directory containing the OpenCV dll and then add the CUDA directory and any other directories containing required dll’s until it starts to work. This sometimes fixes python 3.8 issues.

I tried adding the code in ___init__.py, same error. I also tried adding build\bin\Release, result is still the same.

Are you sure the .pyd in C:/DevHome/Program/Python/Python38/Lib/site-packages/cv2/python-3.8 corresponds to the .dll in
C:\DevHome\Program\OpenCV450\build\bin\Release and not one you previously build?

I would also try deleting the cv2 dir and copying the pyd directly into the
C:/DevHome/Program/Python/Python38/Lib/site-packages/ directory.

Got the result of the opencv_test_core.exe:

[----------] Global test environment tear-down
[ SKIPSTAT ] 35 tests skipped
[ SKIPSTAT ] TAG='mem_6gb' skip 1 tests
[ SKIPSTAT ] TAG='skip_bigdata' skip 1 tests
[ SKIPSTAT ] TAG='skip_other' skip 33 tests
[==========] 11587 tests from 244 test cases ran. (547541 ms total)
[  PASSED  ] 11583 tests.
[  FAILED  ] 4 tests, listed below:
[  FAILED  ] Core_InputOutput.filestorage_base64_basic_read_XML
[  FAILED  ] Core_InputOutput.filestorage_base64_basic_read_YAML
[  FAILED  ] Core_InputOutput.filestorage_base64_basic_read_JSON
[  FAILED  ] Core_globbing.accuracy

 4 FAILED TESTS
  YOU HAVE 19 DISABLED TESTS

You may also want to try
opencv_test_cudaarithm.exe
Additionally you don’t need OPENCV_ENABLE_NONFREE for CUDA so you could try building without it, if you are 100% this is causing the problem.

Failing that try anaconda and dload the binaries from

I tried this, same result (no error on init.py now):

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing cv2: The specified module could not be found.

I would now give the below a second shot in the python terminal before importing cv2.

You could also try

import os
os.add_dll_directory(‘C:\DevHome\Program\OpenCV450\build\lib\Release’)

if that’s the directory containing the OpenCV dll and then add the CUDA directory and any other directories containing required dll’s until it starts to work. This sometimes fixes python 3.8 issues.

Ah, I actually need the OPENCV_ENABLE_NONFREE. I believe I read James Bowley’s blog and tried the steps of code rebuild there as well (via CMD, though I prefer CMake GUI). It was really weird that my first build before was ok. Looking at the apps I installed after that, maybe one of them is the culprit?

So the timeline is:

Currently, I didn’t enable CUDA yet so the test is not available now.

Here’s the output:

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.add_dll_directory('C:\\DevHome\\Program\\OpenCV450\\build\\lib\\Release')
<AddedDllDirectory('C:\\DevHome\\Program\\OpenCV450\\build\\lib\\Release')>
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing cv2: The specified module could not be found.
>>> os.add_dll_directory('C:\\DevHome\\Program\\OpenCV450\\build\\bin\\Release')
<AddedDllDirectory('C:\\DevHome\\Program\\OpenCV450\\build\\bin\\Release')>
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing cv2: The specified module could not be found.

Is there a way to change the code in OpenCV to tell me which specific DLL is being loaded?

@cudawarped I didn’t notice that you are James Bowley. Thanks for helping out and great blog site by the way!

I guess I should try your binaries now. Though when I first downloaded it, I didn’t know how to use or install it. Maybe you can help me with that. I still consider myself as a newbie in building source code in Windows using CMake and Visual Studio (though I have lots of Linux experience).

perhaps investigate what DLL it’s missing. it might be something opencv picked up in the build process somewhere, but that isn’t in PATH yet…

also be aware that setting PATH in the system settings does not propagate into running processes. that’s transitive, so you will probably need to log out and back in again to make it work easily. starting processes from Win+R should work as well because that explorer process gets those environment variable updates.

Thanks for helping out @crackwitz . Ah yes, I’m aware about the Path behavior. I always create a new CMD everytime I change Path environment value.

I think one improvement in OpenCV code is to provide a more specific error message on what DLL is being loaded. Is there a way to do that? I tried adding debug info to my Python, still not showing. I heard about Python’s flag -O and -OO but also not helping.

I actually created a batch script to automatically check if DLLs are visible in Path.

@echo off
for /f "tokens=*" %%a in (cv2-dlls.txt) do (
  where %%a
)
pause

Thanks to @cudawarped blog, I learned how to troubleshoot a missing DLL. Here’s the content of my cv2-dlls.txt (thanks to Dependency walker tool):

SHCORE.DLL
SHLWAPI.DLL
IEFRAME.DLL
ADVAPI32.DLL
BCRYPT.DLL
CFGMGR32.DLL
COMBASE.DLL
COMCTL32.DLL
COMDLG32.DLL
CONCRT140.DLL
CRYPT32.DLL
CV2.CP38-WIN_AMD64.PYD
D3D11.DLL
DPAPI.DLL
DXGI.DLL
GDI32.DLL
HDF5.DLL
KERNEL32.DLL
KERNELBASE.DLL
KSUSER.DLL
MF.DLL
MFCORE.DLL
MFPLAT.DLL
MFREADWRITE.DLL
MSVCP140.DLL
MSVCP_WIN.DLL
MSVCRT.DLL
NTDLL.DLL
OLE32.DLL
OLEAUT32.DLL
OPENCV_ARUCO451.DLL
OPENCV_BGSEGM451.DLL
OPENCV_BIOINSPIRED451.DLL
OPENCV_CALIB3D451.DLL
OPENCV_CCALIB451.DLL
OPENCV_CORE451.DLL
OPENCV_DNN451.DLL
OPENCV_DNN_SUPERRES451.DLL
OPENCV_FACE451.DLL
OPENCV_FEATURES2D451.DLL
OPENCV_FLANN451.DLL
OPENCV_FUZZY451.DLL
OPENCV_GAPI451.DLL
OPENCV_HDF451.DLL
OPENCV_HFS451.DLL
OPENCV_HIGHGUI451.DLL
OPENCV_IMG_HASH451.DLL
OPENCV_IMGCODECS451.DLL
OPENCV_IMGPROC451.DLL
OPENCV_INTENSITY_TRANSFORM451.DLL
OPENCV_LINE_DESCRIPTOR451.DLL
OPENCV_MCC451.DLL
OPENCV_ML451.DLL
OPENCV_OBJDETECT451.DLL
OPENCV_OPTFLOW451.DLL
OPENCV_PHASE_UNWRAPPING451.DLL
OPENCV_PHOTO451.DLL
OPENCV_PLOT451.DLL
OPENCV_QUALITY451.DLL
OPENCV_RAPID451.DLL
OPENCV_REG451.DLL
OPENCV_RGBD451.DLL
OPENCV_SALIENCY451.DLL
OPENCV_SHAPE451.DLL
OPENCV_STITCHING451.DLL
OPENCV_STRUCTURED_LIGHT451.DLL
OPENCV_SURFACE_MATCHING451.DLL
OPENCV_TEXT451.DLL
OPENCV_TRACKING451.DLL
OPENCV_VIDEO451.DLL
OPENCV_VIDEOIO451.DLL
OPENCV_XFEATURES2D451.DLL
OPENCV_XIMGPROC451.DLL
OPENCV_XPHOTO451.DLL
PYTHON38.DLL
RPCRT4.DLL
RTWORKQ.DLL
SECHOST.DLL
SHELL32.DLL
USER32.DLL
VCRUNTIME140.DLL
VCRUNTIME140_1.DLL
VERSION.DLL
WIN32U.DLL
WS2_32.DLL
WSOCK32.DLL
ACLUI.DLL
ACTIVEDS.DLL
ADSLDPC.DLL
ADVPACK.DLL
AEPIC.DLL
APPHELP.DLL
AUTHZ.DLL
AVRT.DLL
BCD.DLL
BCP47LANGS.DLL
BCP47MRM.DLL
BCRYPTPRIMITIVES.DLL
BROWCLI.DLL
CABINET.DLL
CERTCA.DLL
CERTENROLL.DLL
CHAKRA.DLL
CHARTV.DLL
CLDAPI.DLL
COMCTL32.DLL
COML2.DLL
COMPPKGSUP.DLL
CONTACTACTIVATION.DLL
COREMESSAGING.DLL
COREUICOMPONENTS.DLL
CREDUI.DLL
CRYPTBASE.DLL
CRYPTNET.DLL
CRYPTNGC.DLL
CRYPTSP.DLL
CRYPTTPMEKSVC.DLL
CRYPTUI.DLL
CRYPTXML.DLL
CSCAPI.DLL
D2D1.DLL
D3D11ON12.DLL
D3D12.DLL
D3DSCACHE.DLL
DAVHLPR.DLL
DBGCORE.DLL
DBGENG.DLL
DBGHELP.DLL
DBGMODEL.DLL
DCOMP.DLL
DEVMGR.DLL
DEVOBJ.DLL
DEVRTL.DLL
DFSCLI.DLL
DHCPCSVC.DLL
DHCPCSVC6.DLL
DMCMNUTILS.DLL
DMENTERPRISEDIAGNOSTICS.DLL
DMPUSHPROXY.DLL
DNSAPI.DLL
DRVSETUP.DLL
DRVSTORE.DLL
DSCLIENT.DLL
DSPARSE.DLL
DSREG.DLL
DSROLE.DLL
DUI70.DLL
DUSER.DLL
DWMAPI.DLL
DWRITE.DLL
DXILCONV.DLL
EAPPCFG.DLL
EAPPPRXY.DLL
EDGEISO.DLL
EDPAUDITAPI.DLL
EDPUTIL.DLL
EFSADU.DLL
EFSCORE.DLL
EFSUTIL.DLL
EFSWRT.DLL
ELSCORE.DLL
ESENT.DLL
EVR.DLL
FECLIENT.DLL
FIREWALLAPI.DLL
FLTLIB.DLL
FMS.DLL
FVEAPI.DLL
FVECERTS.DLL
FVESKYBACKUP.DLL
FWBASE.DLL
FWPOLICYIOMGR.DLL
GDIPLUS.DLL
HID.DLL
HTTPAPI.DLL
ICU.DLL
ICUIN.DLL
ICUUC.DLL
IEADVPACK.DLL
IEAPFLTR.DLL
IERTUTIL.DLL
IEUI.DLL
IMAGEHLP.DLL
IMGUTIL.DLL
IMM32.DLL
INETCOMM.DLL
IPHLPAPI.DLL
IRI.DLL
LINKINFO.DLL
LOGONCLI.DLL
MDMREGISTRATION.DLL
MFASFSRCSNK.DLL
MFC42U.DLL
MFNETCORE.DLL
MFNETSRC.DLL
MFTRANSCODE.DLL
MI.DLL
MIUTILS.DLL
MLANG.DLL
MMDEVAPI.DLL
MPR.DLL
MPRMSG.DLL
MRMCORER.DLL
MSASN1.DLL
MSCTF.DLL
MSFEEDS.DLL
MSHTML.DLL
MSI.DLL
MSILTCFG.DLL
MSIMG32.DLL
MSISO.DLL
MSLS31.DLL
MSOERT2.DLL
MSVCP110_WIN.DLL
NCRYPT.DLL
NETAPI32.DLL
NETUTILS.DLL
NEWDEV.DLL
NGCRECOVERY.DLL
NSI.DLL
NTASN1.DLL
NTDSAPI.DLL
NTSHRUI.DLL
OCCACHE.DLL
OLEACC.DLL
OLEDLG.DLL
OMADMAPI.DLL
ONEX.DLL
POLICYMANAGER.DLL
POWRPROF.DLL
PRINTUI.DLL
PROFAPI.DLL
PROPSYS.DLL
PUIAPI.DLL
RASAPI32.DLL
RASMAN.DLL
REGAPI.DLL
RMCLIENT.DLL
RTUTILS.DLL
SAMCLI.DLL
SAMLIB.DLL
SCECLI.DLL
SECUR32.DLL
SETUPAPI.DLL
SHDOCVW.DLL
SLC.DLL
SPFILEQ.DLL
SPINF.DLL
SPPC.DLL
SRPAPI.DLL
SRVCLI.DLL
SSPICLI.DLL
TBS.DLL
TEXTINPUTFRAMEWORK.DLL
TEXTSHAPING.DLL
TOKENBINDING.DLL
TPMCOREPROVISIONING.DLL
TWINAPI.APPCORE.DLL
TWINAPI.DLL
UIAUTOMATIONCORE.DLL
UMPDC.DLL
URLMON.DLL
USERDATATYPEHELPERUTIL.DLL
USERENV.DLL
UXTHEME.DLL
VAULTCLI.DLL
VIRTDISK.DLL
W32TOPL.DLL
WEBAUTHN.DLL
WEBIO.DLL
WEBSERVICES.DLL
WEBSOCKET.DLL
WER.DLL
WEVTAPI.DLL
WFDSCONMGR.DLL
WINBRAND.DLL
WINDOWSCODECS.DLL
WINDOWSPERFORMANCERECORDERCONTROL.DLL
WINHTTP.DLL
WININET.DLL
WINIPCFILE.DLL
WINMM.DLL
WINMMBASE.DLL
WINMSIPC.DLL
WINNSI.DLL
WINSPOOL.DRV
WINSTA.DLL
WINTRUST.DLL
WKSCLI.DLL
WLANAPI.DLL
WLDAP32.DLL
WLDP.DLL
WMICLNT.DLL
WPAXHOLDER.DLL
WTSAPI32.DLL
WUCEFFECTS.DLL
XMLLITE.DLL

that, unfortunately, is an error generated by python. OpenCV can’t affect that.

it would be nice indeed if python could look into what dll failed to load… they probably would, if windows provided that information trivially.

the existence of Dependency Walker tells me that this problem won’t be a quick fix. likely microsoft would have to get off their asses and sit down to stomp a new API out of the ground.

Don’t forget any path. To use my own python binding I use

import os
os.add_dll_directory(r'G:\Lib\install\opencv\x64\vc15\bin')
os.add_dll_directory(r'G:\Lib\install\vtk\bin')
os.add_dll_directory(r'F:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin')
os.add_dll_directory(r'F:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2')
import cv2 as cv

check this issue too Python Bindings importing error · Issue #17632 · opencv/opencv · GitHub and the reason is discussed here Issue 36085: Enable better DLL resolution - Python tracker

2 Likes

I’ve had to fight with gstreamer… it has its own pile of dll somewhere, AND THEY NAME-CLASH with other DLLs on my system that are system/runtime-related.

just thought I should mention it.

1 Like