Import cv2 error

You won’t believe that I’ve been struggling with running OpenCV for over a week and a half now. I’ve tried installing it in every possible way, but I keep encountering an issue when trying to import cv2 in Python command prompt. The problem is that there is no cv2.cp310-win_amd64.pyd file generated after the build process. I’ve tried several versions of OpenCV and Python, as well as Visual Studio 2022 and 2019.

Here are some details about my setup:

  • Windows 11
  • CUDA 12.4.1
  • cuDNN 9.1.1
  • opencv-4.x.zip + opencv_contrib-4.x.zip
  • I’ve also tried OpenCV versions 4.9, 4.8, and 4.5.5

I’ll attach the logs from CMake configurations and the build process from Visual Studio for your reference.

https://drive.google.com/drive/folders/18dYQxMRC6c4Gq7JK9n0b1ZPAtLteXrIS?usp=drive_link

Note: After completing the installation and accessing the Python file in Visual Studio Code, import cv2
from cv2 import dnn_superres
works without any issues. However, I’m unable to use the code in the command prompt.

Your getting a lot of build errors because your using CUDA 12.4. This wasn’t supported untill

and

Build against latest commits from both 4.x branches. If you are still having issues then please post the resulting CMake output.

3 posts were split to a new topic: Building on Windows, getting ImportError: DLL load failed while importing cv2