I have installed OpenCV in Python 3.6(64 bit), but whenever I compile the below code, it is throwing an error of module object has no attribute imread and imshow
.
This happens while doing in the python idle
but when trying in the command-line interpreter with windows 10 it is working. Moreover while getting opencv version, the command-line code is working but not with idle.
Please give the possible solution for this problem.
Python IDLE:
import numpy as np
import cv2
img = cv2.imread("H:\python project\watch.jpg",0)
cv2.imshow("image",img)
python IDLE error msg:
Traceback (most recent call last):
File "H:\python project\cv2.py", line 3, in <module>
import cv2
File "H:\python project\cv2.py", line 5, in <module>
img = cv2.imread("H:\python project\watch.jpg",0)
AttributeError: module 'cv2' has no attribute 'imread'