Open 11philip22 opened 1 year ago
I have exactly this issue. Is there a simple way to see which DLL failed to load, that sounds like a natural starting point for investigation.
After some investigation I see it fails on init.py in the cv2 folder on the line native_module = importlib.import_module("cv2") No idea why yet
Is there a solution to this?
Same problem, is there a solution ?
The instructions are a little out of date, but I believe they would solve the issue Go to Windows -> Settings -> Uninstall/Install Apps Go to Optional Features Go to Add button Look for Windows Media Pack
@GenericAccount2 This was the solution. Thank you.
I think that OpenCV should consider updating their documentation. This is a frustrating error to encounter, and if documentation is out of date, and cannot be followed, nobody is normally going to self-solve their issue.
No idea which documentation you want to read.
https://pypi.org/project/opencv-python/
Q: Import fails on Windows: ImportError: DLL load failed: The specified module could not be found.? A: If the import fails on Windows, make sure you have Visual C++ redistributable 2015 installed. If you are using older Windows version than Windows 10 and latest system updates are not installed, Universal C Runtime might be also required. Windows N and KN editions do not include Media Feature Pack which is required by OpenCV. If you are using Windows N or KN edition, please install also Windows Media Feature Pack. ...
And this is a copy of top level README of this project:
In your Python environment, execute this code and install the required packages. For example, I created a virtual environment with conda, I executed "conda install numpy protobuf hdf5 cudnn cudatoolkit". I don't know if "cudnn cudatoolkit" has to be installed. Since I compiled OpenCV with CUDA, I need to install it.
Trying to run https://github.com/cudawarped/opencv-python-cuda-wheels on python 3.11 on Windows Server compiled by @cudawarped and getting import DLL error. All DLLs seem to be there. Not an issue when using python 3.7 on the same system.
Trying to run https://github.com/cudawarped/opencv-python-cuda-wheels on python 3.11 on Windows Server compiled by @cudawarped and getting import DLL error. All DLLs seem to be there. Not an issue when using python 3.7 on the same system.
This is not an officially supported release. Please raise an issue on that repo with more details regarding your setup and which wheel you are using and I'll take a look.
@cudawarped solved as part of: https://github.com/opencv/opencv-python/issues/955
I have tried the solution of Windows Media pack and still I have the same issue. But i have the following paths in the environment variables:
I have tried the solution of Windows Media pack and still I have the same issue
Use process monitor to track down the missing dll. See ImportError: DLL load failed while importing cv2: The specified module could not be found
I got the same problem.
I have the same problem (Python 3.11)
@jason660519 and @fluviotect when you ran process monitor which dll's couldn't it find?
At least for me the issue seems to be __init__.cp311-win_amd64.pyd
and __init__.pyd
. For everything else Process Monitor eventually displays a SUCCESS-message.
I am using Windows 11 Enterprise, OpenCV 4.6.0 and Python 3.11.8. Using 3.10.14 does not change the behaviour.
I tried looking for the Windows Media Pack but is it neither offered as an optional feature nor does it show up as an installed feature. So maybe my issues is something completely different.
@catequalsgood I am presuming you are using a script to parse the process monitor output which is how you managed to filter it down to only those two entries, making the result extreemly odd.
Specifically I can't understand why python would be outputing an error that it can't find all the dll's when it has found them.
I was not using a script but I changed that and looked at the log again. I did indeed miss one. intl.dll
also never shows SUCCESS.
You may find it much easier to parse the exported list, see https://forum.opencv.org/t/dll-load-failed-when-importing-a-self-built-cv2-library-in-python/16942/15
The output seems equivalent. More DLLs like VERSION.dll
are returned because only loading version.dll
is successful. __init__.cp311-win_amd64.pyd
as well as __init__.pyd
are of course missing from the output. Leaving only intl.dll
this is such a growing issue.. I am unable to import cv2 for days and my whole project is stuck!
@SubhamBurnwal-BiswaGames Did you build it yourself? If so did you check for the missing dll using process explorer and if so what was missing?
I too was facing the same issue. I have python 3.11.7 in my conda env and I used conda to install opencv and I faced the same import error. I reinstalled the Visual C++ redistributables, checked if opencv package was present in anaconda and even then I couldn't solve the issue. Then I noticed that conda by default installs opencv 4.7 and the lastest version was opencv 4.9. So I used pip to install the latest release of opencv 4.8.1.78 and now I can import the cv2 module successfully.
For me, gstream runtime dll are not in site-packages\cv2 folder. I'm using the way mentioned at here:, i.e. add following before import cv2: import os gst_root = os.getenv('GSTREAMER_1_0_ROOT_MSVC_X86_64', 'C:/gstreamer/1.0/msvc_x86_64/') os.add_dll_directory(gst_root+'bin') import cv2
I too was facing the same issue. I have python 3.11.7 in my conda env and I used conda to install opencv and I faced the same import error. I reinstalled the Visual C++ redistributables, checked if opencv package was present in anaconda and even then I couldn't solve the issue. Then I noticed that conda by default installs opencv 4.7 and the lastest version was opencv 4.9. So I used pip to install the latest release of opencv 4.8.1.78 and now I can import the cv2 module successfully.
I used Anaconda Navigator to install opencv and got version 4.6.6. Then I had this "DLL load failed while importing cv2" issue. I tried to use "Process Monitor" suggested by other link and found that "intl.dll" was not found. After seeing Raknash3's comment, I removed the opencv with Anaconda Navigator and tried "conda install -c conda-forge open.cv" and had 4.7.0 installed. Now it works. Thanks.
encountered this error on Windows 11 Enterprise N. To fix it, I installed the Media Feature Pack by going to Settings > System > Optional Features > Add an Optional Feature. If the issue persists after installing the Media Feature Pack, try reinstalling OpenCV."
Hi, I installed opencv-contrib-python 4.7.0.72 using pip for python 3.11.4 on Windows 10 x86-64 But when I run I get this exceptiom
DLL load failed while importing cv2: The specified module could not be found.
Expected behaviour
I expect the module to import and not trow an error.
Actual behaviour
This exception gets trown
Steps to reproduce
import cv2
Issue submission checklist
[x] This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
[x] I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
opencv-python