“DLL load failed” when import cv2 (opencv)

前端 未结 15 1009
萌比男神i
萌比男神i 2020-12-14 08:45

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

pip install opencv-contrib-python

installed without any error .
and when I try to impor

相关标签:
15条回答
  • 2020-12-14 09:05

    I had the same problem on Windows Server 2012 R2 x64. I was creating executable file using PyInstaller and got error in runtime:

    ImportError: DLL load failed: The specified module could not be found.
    

    After installing "Visual C++ redistributable" 2015 and enabling "Media Foundation" feature my problem was resolved.

    There is more informations in documentation: OpenCV Documentation

    0 讨论(0)
  • 2020-12-14 09:06

    I have faced the similar issue in Windows Server 2012 r2. 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 opencv would be available.

    0 讨论(0)
  • 2020-12-14 09:08

    This can happen if you are using windows 10 N distribution, the N distributions does not come pre installed with windows media feature pack, which is required after OpenCV version 3.4 and onwards.

    The preferred solution is to install the feature pack at : https://www.microsoft.com/en-us/software-download/mediafeaturepack

    Be careful to choose the version that works with your current version of windows.

    If that is not an option, fall back to an earlier version of OpenCV that does not have dll dependencies, you can do that by:pip install opencv-python=3.3.0.9

    Since windows rolled out it's N version this problem has been seen at many places, and has many impacts across the windows environment, the fastest way to identify if you have this problem is open youtube in Edge browser, if it says HTML5 media plugin not found, this is the problem.

    Update May 2020: There is a new way to install media pack for Windows 10 N.

    https://support.microsoft.com/en-us/help/4562569/media-feature-pack-for-windows-10-n-may-2020

    0 讨论(0)
  • 2020-12-14 09:08

    Can you try uninstalling opencv and installing it using a wheel file instead? Here is a website that has many versions of OpenCV compiled for windows, search for the one you need and simply install it with pip command.

    So if you have Python 3.6 (64 Bit) and wish to install OpenCV 3.4.3 then download the wheel file: opencv_python‑3.4.3‑cp36‑cp36m‑win_amd64.whl

    0 讨论(0)
  • 2020-12-14 09:10

    I had the same error (although 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.

    0 讨论(0)
  • 2020-12-14 09:11

    I had similar issue except that I'm using Anaconda3 and this code here solved it:

    conda install -c anaconda py-OpenCV
    
    0 讨论(0)
提交回复
热议问题