0

I installed OpenCV using command

pip install OpenCV-python

in python 3.6.0 but shows error when I used in code
code

    import cv2 
    def vidPlay(): 
       cap = cv2.VideoCapture(0)
       ret, inputImage = cap.read() 
       if ret==True:
           return inputImage
       cap.release()
    a = vidPlay()
    print(a)
    print("done ")
    cv2.imshow(a)

Error

     File "<stdin>", line 1, in <module>
  File "C:\Users\yyy\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
    execfile(filename, namespace)
  File "C:\Users\yyy\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)
  File "C:/Users/yyy/Desktop/cameraPlay.py", line 1, in <module>
    import cv2 
  File "C:\Users\yyy\Anaconda3\lib\site-packages\cv2\__init__.py", line 7, in <module>
    from . import cv2
ImportError: DLL load failed: The specified module could not be found.

i tried different solutions on questions but not solve my issue.

Arslan Ahmad khan
  • 5,426
  • 1
  • 27
  • 33

1 Answers1

0

This question seems to be a duplicate of the following question:

DLL Load Failed Error when importing CV2

I'm copying the accepted answer from that question, for the ease:

You can download the latest OpenCV 3.2.0 for Python 3.6 on Windows 32-bit or 64-bit machine, look for file starts withopencv_python‑3.2.0‑cp36‑cp36m, from this unofficial site. Then type below command to install it:

pip install opencv_python‑3.2.0‑cp36‑cp36m‑win32.whl (32-bit version) pip install opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl (64-bit version) I think it would be easier.

Written by: @thewaywewere

d3corator
  • 1,154
  • 1
  • 9
  • 23