0

I know that there are many questions and answers regarding this. But I couldn't solve it. I get

ImportError: DLL load failed while importing cv2: The specified module could not be found.

I have Windows 11, Python 3.9.12

opencv-python and opencv-contrib-python 4.6.0.66

PyCharm IDE

I tried

  • installing Visual build tools
beaker
  • 16,331
  • 3
  • 32
  • 49
thestruggleisreal
  • 940
  • 3
  • 10
  • 26
  • You may run into some problems running both of the opencv packages. Only have 1 installed at a time. The contrib package contains some more contributions than the other package. You should probably INSTALL: opencv-contrib-python, and UNINSTALL: opencv-python. Try running after doing my suggestion – mrblue6 Feb 08 '23 at 16:00
  • after uninstalling opencv-python, I get the same error – thestruggleisreal Feb 08 '23 at 16:34
  • Your question was asked on the opencv docs in FAQs section: https://pypi.org/project/opencv-python/ There is also this stackoverflow thread with many responses: https://stackoverflow.com/questions/43184887/dll-load-failed-error-when-importing-cv2 You could also try using opencv-python instead of the contrib package Did you install with pip or some other way? – mrblue6 Feb 08 '23 at 17:03

1 Answers1

0

OpenCV Python library is an Interface to C++ library, so in order to run the code, you should install the CMake.

$ apt-get update && apt-get install -y cmake build-essential libgtk-3-dev libboost-all-dev

If you are trying to run it in docker, just change the $ to a RUN before install requirements.txt.

I hope this help you. Obs: I'm also using Windows 11 and WSL2. For me, it takes around 10 minutes to complete the apt and pip install, but worked for me.