0

Recently I needed the opencv library. I created a project, made a virtual environment, installed numpy and opencv in it. When trying to import the cv2 module, the following error appears in the console:

File "C:\Users\perfe\Desktop\cv\main.py", line 2, in <module>
    import cv2
  File "C:\Users\perfe\Desktop\cv\lib\site-packages\cv2\__init__.py", line 181, in <module>
    bootstrap()
  File "C:\Users\perfe\Desktop\cv\lib\site-packages\cv2\__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "C:\Users\perfe\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing cv2: The specified module was not found.

I deleted the module, tried reinstalling it, but in a different way: pip install opencv-contrib-python. Result - same error.

How to fix the error? If I haven't found some obvious solution, don't hit me. :)

  • I think this is a duplicate of this question: https://stackoverflow.com/questions/43184887/dll-load-failed-error-when-importing-cv2 – starking Mar 26 '23 at 08:59

1 Answers1

1

The answer can be found in this post here on stack overflow: DLL load failed error when importing cv2

Run:

pip install opencv-contrib-python
starking
  • 153
  • 10