Search code examples
pythonopencv

AttributeError: module 'cv2' has no attribute 'VideoCapture'


I had some problems with Opencv in Python.

This attribute problem also happens with imread

I tried to uninstall and reinstall with contrib-Opencv,but it did not work.

About 2 months ago, my opencv file still worked well, but I don't know why it doesn't work now.

In the next reinstallations,this command always sastifies but no good results

import cv2
cap = cv2.VideoCapture(0)
...
cap.release()

My error command:

Traceback (most recent call last):
  File "C:\Users\Hoang Cao Chuyen\Documents\pyml\cv11.py", line 4, in <module>
    cap = cv2.VideoCapture(0)
AttributeError: module 'cv2' has no attribute 'VideoCapture'
[Finished in 0.2s with exit code 1]
[shell_cmd: python -u "C:\Users\Hoang Cao Chuyen\Documents\pyml\cv11.py"]

Solution

  • After asking my friend,i had the solution.It is very easy because i saved this file in Documents path in user which my private name Hoang Cao Chuyen without '_'.I changed into another path,and it was OK.