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. :)