"DLL load failed" when import cv2 (opencv)

1094 views python

i spent many hours to solve this problem but i can't find soloution , please any clue that you know share with me.

in [windows server 2012 R2 x64, python 3.7 64x]

pip install opencv-contrib-python

installed without any error .

and when i try to import it

import cv2

show me this error :

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import cv2
  File "C:\Program Files\Python37\lib\site-packages\cv2\__init__.py", line 3, in
    from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.

and i see another topics about this error but their soloution is not work for me :
- DLL load failed error when importing cv2
- Failure to import cv2 in python : DLL load failed
- and a lot of pages in here

some of them say about that problem because anaconda , and i don't have anaconda even . and many say that problem 32 or 64 version , i try both and disappointment . many about system variables...
what dll failed to load? cv2? why ?

what i try till now:
- change python version : 3.5, 3.7, 2.7 in 86x and 64x (uninstall complete last version and delete all remain files in program files ... then install new one)
- try with another packages like : opencv-python, opencv-contrib, try install specific versions with .whl (in some topic i read about this so install numpy-1.14.5+mkl-cp37-cp37m-win_amd64.whl and opencv_python-3.4.3+contrib-cp37-cp37m-win_amd64.whl but anything not change)
- import numpy before cv2 for every test
- installed Microsoft Visual C++ 2015 Redistributable Update 3 , 2008 , 2010 , 2017 for 64x

please help me.

answered question

1 Answer


I had the same error (altough I compiled opencv myself), in my case there were some DLL dependencies missing. You can check that with the program Dependency Walker.

Download Dependency Walker and run it, and open the file cv2.pyd with Dependency Walker, it should be in C:\Program Files\Python37\lib\site-packages\cv2\ if the pip package installed correctly.

This program then scans for dependencies (which may take a few minutes) and it then shows missing DLL files in red.

posted this

Have an answer?


Please login first before posting an answer.