DLL Load Failed Error When Importing cv2 on Windows 11 Pro

strong text> Traceback (most recent call last): \Masaüstü\heatmap\heatmapp.py",

line 2, in import cv2

List item

File “C:\Users\MikailAkdeniz\AppData\Local\Programs\Python\Python312\Lib\site-packages\cv2_init.py", line 181, in bootstrap() File "C:\Users\MikailAkdeniz\AppData\Local\Programs\Python\Python312\Lib\site-packages\cv2init.py", line 153, in bootstrap native_module = importlib.import_module(“cv2”) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\MikailAkdeniz\AppData\Local\Programs\Python\Python312\Lib\importlibinit_.py”, line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ImportError: DLL load failed while importing cv2: Belirtilen modül bulunamadı.

I am using Python 3.12 and OpenCV 4.10 on Windows 11 Pro. My code, which was working fine previously, started giving a “DLL load failed” error when importing cv2 this morning. The same code was working without issues before. What should I do to resolve this problem? What solutions would you recommend for this situation?

Did you build it yourself, if so check which DLL is now missing

If you didn’t build it yourself have you tried removing and re-installing with pip?

Haha, today I was reading the responses you gave to other users, and when I shared my problem here, I was praying to God that you would answer me. :):):slight_smile: Yes, I uninstalled and reinstalled using pip, but it still didn’t solve the issue. I think the problem might be with Python…

I didn’t make any changes to my code or system. Yesterday, my code and system were working fine, but today when I tried to run my code again, it gave me an error.

It might still be worth checking which dll is missing. Other than that I can’t think of anything, the official pre-built wheels tend to just work, unless you have multiple versions installed (mixing opencv-python with opencv-contrib-python) or you have built it yourself.

@berak @crackwitz any suggestions?

Yes, it was working smoothly. I detected objects with YOLO, generated heatmaps, and even installed CUDA for GPU acceleration. I’ve been working on this for two weeks now. I will try again with Python 3.11, and if it doesn’t work, I’ll report back in the comments…:)(

So you built it yourself?

Locating the missing DLL using process explore will be a much more efficient use of your time than re-building for python 3.11.

I don’t know how to find the missing DLL. This is the first time I have encountered this situation, and what confuses me is that the working code broke on its own.

Thank you very much for your help. I solved my issue by installing Python 3.11, and my code finally ran without any problems.

crosspost:

Hello, as I mentioned yesterday, I installed Python 3.11 and then recompiled OpenCV with CUDA. I was working on YOLO with CUDA as well, but now when I run PyTorch 12.4 with CUDA, I’m getting this error for YOLO: “could not load symbol cudnngetlibconfig. error code 127.” Later, when I tried running my YOLO code with another PyTorch version, I got this error instead: “OSError: [WinError 127] The specified procedure could not be found. Error loading ‘C:\Users\MikailAkdeniz\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\lib\cufftw64_11.dll’ or one of its dependencies.” What should I do? Can you help?

Sorry but your not providing enough information every time you post so its difficult to help you, and you have a pytorch not OpenCV issue.

If I were to guess I would say your installing different versions of CUDA one for pytorch and one for building OpenCV but I could be wrong as its not clear exactly whats working and at what point you are breaking it. i.e. does it work then you install pytorch and it breaks, when you say it worked one day and then stopped something must have changed, why did you think python 3.11 would work, that’s an odd conclusion to come to etc. etc.

Anyway you can try a pre-build wheel if you have CUDA 12.5 and the latest version of cuDNN installed