opencv / opencv-python

Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.
https://pypi.org/project/opencv-python/
MIT License
4.43k stars 833 forks source link

ImportError: DLL load failed while importing cv2 #978

Open qiaoqiaobangya opened 4 months ago

qiaoqiaobangya commented 4 months ago

I have a problem "ImportError: DLL load failed while importing cv2: The specified module could not be found"

Information about my attempted installation Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32 MSVC: Microsoft Visual Studio 2019 OS: Win 10 CMake gui: 3.29.2 Source cv2 files version: 4.5.0

I'm compiling opencv from source and it's all working fine, but when instantiating cv2, I get the "Import DLL .... " error occurred. Python 3.8.10 opencv 4.5.0 opencv_contrib-4.5.0

What is the DLL file that failed to load? Why is this happening? Also I would like to know if it is possible to make opencv implement CUDA acceleration by compiling opencv source code in the python case. If it is possible how to implement it?

Thank you, Anthony of Sydney

asmorkalov commented 3 months ago

The provided information is not enough to debug the issue. Two instances of OpenCV package may cause dll mix. Please ensure that you remove the first instance, when tries another one.

asmorkalov commented 3 months ago

You case also trace OpenCV loading process by setting sys.OpenCV_LOADER_DEBUG = 1 before OpenCV import.

Avasam commented 1 month ago

This could also be a duplicate of either https://github.com/opencv/opencv-python/issues/771, https://github.com/opencv/opencv-python/issues/856 and/or https://github.com/opencv/opencv-python/issues/976