DLL load failed error when importing cv2
Solution 1
You can download the latest OpenCV 3.2.0 for Python 3.6 on Windows 32-bit or 64-bit machine, look for file starts withopencv_python‑3.2.0‑cp36‑cp36m
, from this unofficial site. Then type below command to install it:
-
pip install opencv_python‑3.2.0‑cp36‑cp36m‑win32.whl
(32-bit version) -
pip install opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl
(64-bit version)
I think it would be easier.
Update on 2017-09-15:
OpenCV 3.3.0
wheel files are now available in the unofficial site and replaced OpenCV 3.2.0
.
Update on 2018-02-15:
OpenCV 3.4.0
wheel files are now available in the unofficial site and replaced OpenCV 3.3.0
.
Update on 2018-06-19:
OpenCV 3.4.1
wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7
support, and replaced OpenCV 3.4.0
.
Update on 2018-10-03:
OpenCV 3.4.3
wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7
support, and replaced OpenCV 3.4.1
.
Update on 2019-01-30:
OpenCV 4.0.1
wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7
support.
Update on 2019-06-10:
OpenCV 3.4.6
and OpenCV 4.1.0
wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7
support.
Solution 2
I took a lot of time to solve this error! Run command
pip install opencv-contrib-python
Solution 3
If you are using Anaconda with python 3.5
, this is a problem in the Anaconda release. (Refer this issue)
You can fix this issue by copying python3.dll
file to Anaconda3
folder (where python.exe
is located)
How to get "python3.dll"
- In
cmd
, typepython --version
to find whether your installation is 64-bit or 32-bit - download python 3.x embeddable zip file from here
- Extract the zip file and copy
python3.dll
file toAnaconda3
folder
But if you can move to Anaconda
with python 3.6
you will not face this issue. If it is possible for you, then it is the recommended way..
Solution 4
Recently I have faced the similar issue in Azure Windows Server 2012 r2 . Tried all option with and without Anaconda but none of them helped. After lot of findings I found that mfplat.dll was missing which is related to Window Media Service.
Hence you have to manually install the features so that you can get dll related to window media service.
1.Turn windows features on or off
2.Skip the roles screen and directly go to Feature screen
3.Select "Desktop Experience" under "User Interfaces and Infrastructure"
After this all required dll of media services for opencv would be available.
So if you are planning to run your code in cloud(Window Server) then please dont forget to select Desktop Experience feature.
Solution 5
I ran into this problem on Windows 10 (N) with a new Anaconda installation based on Python 3.7 (OpenCV version 4.0). None of the above advice helped (such as installing OpenCV from the unofficial site nor installing VC Redistributable).
I checked DLL dependencies of ...\AppData\Local\conda\conda\envs\foo\Lib\site-packages\cv2\cv2.cp37-win_amd64.pyd
using dumpbin.exe
according to this github issue. I noticed a library MF.dll
, which I figured out belongs to Windows Media Foundation.
So I installed Media Feature Pack for N versions of Windows 10 and voilà, the issue was resolved!
Cameron Wasilewsky
Updated on July 05, 2022Comments
-
Cameron Wasilewsky almost 2 years
I have installed opencv on my windows machine using python 3.6 without any issues, using:
pip install opencv-python
but when I try to import cv2 I get the following error
ImportError: DLL load failed: The specified module could not be found.
I have seen this post
It says cv2 doesn't work with python 3 I was wondering if this has been fixed or if there is a way around it
-
thewaywewere about 7 yearsAN UPDATE:
opencv3.2.0
withopencv_contrib
binaries forPython 3.5 and 3.6
are now available for download from the unoffice site. Look for entry consists of+contrib
in the file name. For example,opencv_python‑3.2.0+contrib‑cp35‑cp35m‑win_amd64.whl
. -
thewaywewere about 7 years
cv2
doesn't meanOpenCV 2.x.x
. To useOpenCV 3.x.x
, has toimport cv2
.OpenCV2.x.x
is relatively old, seems no one compiled it forPython 3.x
and upload to Anaconda Repository. Refer to this post on the file page to find out theOpenCV
and supportedPython
version. -
Stepan Yakovenko over 6 yearsRequirement 'opencv_python-3.2.0-cp36-cp36m-win_amd64.whl' looks like a filename, but the file does not exist
-
thewaywewere over 6 yearsIt looks that
opencv 3.2 for python 3.x
are removed after my UPDATE. You may useopencv 3.3
. -
Vasif over 6 yearsI think the right answer is open cv isn't supported in py-3.6. (based on comment on the question). Also, there is lot of formatting options out here.. for example, you could say
import cv2
instead of "import cv2". just use ` for quotes.. welcome to SO. -
bommina over 6 yearsit works great... after spending 4 hrs, came to this post... helped me alot. currently using Anaconda3-4.1.1-Windows-x86_64 with Python 3.5.2 :: Continuum Analytics, Inc.
-
Stefan Monov over 6 yearsA note for those who don't know, like I didn't: the
cp
in filenames there stands for CPython, so the number after that is your Python version. -
Georgii Oleinikov almost 6 yearsNone of the other answers helped but this one did. Rolling back opencv-python from 3.4 to 3.1.0.5 worked
-
Nicky Manali over 5 yearsThanxx brother this is the best solution. Those who got the same error don't degrade the version just paste this dll file in system32 and systemWOW64
-
roachsinai over 5 yearsThere are several issue about this question, but I find it's platform is not Windos10 + Python3.7.0. And your answer is works for me. Thanks a lot.
-
Matthew over 5 yearsIt worked for me on Windows Server 2012. Thanks a lot
-
p0w3r over 5 yearsthanks for this answer! You saved me a lot of time and it worked perfectly on my Win2012R2!
-
Lassi Kinnunen over 5 yearsworked for me. I had installed opencv-python and some else, but this was the final thing.
-
Ondra almost 5 yearsThanks. Worked for me (Python 3.6 + OpenCv 3.4). I think the Media Feature Pack might be uninstalled during some major windows update
-
Deepak Rao over 4 yearsRunning Windows Server 2012 R2 on AWS, and this fixed the problem.
-
FraWa over 3 yearsWorks for win7 pyhton3.7.3 (Anaconda) - Thanks
-
Gunner Stone almost 3 yearsWorked for me in a conda environment with python = 3.7.10
-
prosti almost 3 yearsAnaconda bug has been resolved. Best feedback I found on opencv and I wrote the troubleshooting of opencv-dll-load-failed afterwords.
-
swasher over 2 yearsInstalled sucessfully, but got same error. File name
opencv_python-4.5.3-cp310-cp310-win_amd64.whl
, python3.10.0
, win11x64 -
user5541269 over 2 yearsThis was my issue and I don't use Anaconda. There's about 5 missing DLLs if the Media feature pack is not installed. You can go to Settings -> Apps -> Apps & Features then click on "Optional Features" and "+ Add a feature" to install the Media Feature Pack.
-
A.K over 2 yearsThanks for this answer! perfectly worked in Win2012R2 edition.