# Import cv2 error

**URL:** <https://forum.opencv.org/t/import-cv2-error/17827>\
**Category:** Python\
**Tags:** dnn, windows, build, cuda\
**Created:** [June 3, 2024, 3:55am UTC](https://forum.opencv.org/t/import-cv2-error/17827 "2024-06-03T03:55:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed1](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@Ahmed1](https://forum.opencv.org/u/Ahmed1)\
**Post date:** [June 3, 2024, 3:55am UTC](https://forum.opencv.org/t/import-cv2-error/17827/1 "2024-06-03T03:55:48Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![cudawarped](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@cudawarped](https://forum.opencv.org/u/cudawarped)\
**Post date:** [June 3, 2024, 7:20am UTC](https://forum.opencv.org/t/import-cv2-error/17827/2 "2024-06-03T07:20:29Z")

</div>

> [@Ahmed1](#):
>
> I’ve also tried OpenCV versions 4.9, 4.8, and 4.5.5

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

> <https://github.com/opencv/opencv_contrib/pull/3744>
>
> Tries to fix https://github.com/opencv/opencv\_contrib/issues/3690 for CUDA 12.4+…
> Related patch to main repo: https://github.com/opencv/opencv/pull/25658
> 
> Changes:
> \- Added branches to support new variadic implementation of thrust::tuple
> \- Added branch with std::array instead of std::tuple in split-merge and grid operations. The new branch got rid of namespace clash: cv::cuda in OpenCV and ::cuda in CUDA standard library (injected by Thrust). Old tuple branches presumed for compatibility with old code and CUDA versions before 12.4.
> 
> \### Pull Request Readiness Checklist
> 
> See details at https://github.com/opencv/opencv/wiki/How\_to\_contribute#making-a-good-pull-request
> 
> \- \[x\] I agree to contribute to the project under Apache 2 License.
> \- \[x\] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
> \- \[x\] The PR is proposed to the proper branch
> \- \[x\] There is a reference to the original bug report and related work
> \- \[\] There is accuracy test, performance test and test data in opencv\_extra repository, if applicable
> Patch to opencv\_extra has the same branch name.
> \- \[\] The feature is well documented and sample code can be built with the project CMake

and

> <https://github.com/opencv/opencv/pull/25658>
>
> Tries to fix https://github.com/opencv/opencv\_contrib/issues/3690 for CUDA 12.4+…
> Related PR to Contrib: https://github.com/opencv/opencv\_contrib/pull/3744 
> 
> \### Pull Request Readiness Checklist
> 
> See details at https://github.com/opencv/opencv/wiki/How\_to\_contribute#making-a-good-pull-request
> 
> \- \[x\] I agree to contribute to the project under Apache 2 License.
> \- \[x\] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
> \- \[x\] The PR is proposed to the proper branch
> \- \[x\] There is a reference to the original bug report and related work
> \- \[\] There is accuracy test, performance test and test data in opencv\_extra repository, if applicable
> Patch to opencv\_extra has the same branch name.
> \- \[\] The feature is well documented and sample code can be built with the project CMake

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

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [June 6, 2024, 4:42am UTC](https://forum.opencv.org/t/import-cv2-error/17827/3 "2024-06-06T04:42:51Z")

</div>

3 posts were split to a new topic: [Building on Windows, getting ImportError: DLL load failed while importing cv2](https://forum.opencv.org/t/building-on-windows-getting-importerror-dll-load-failed-while-importing-cv2/17858)
