-1

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'
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Aj_kumar
  • 11
  • 2
  • 2

1 Answers1

0

Try to import cv2 package in command line. If it executes without any error than it should work. Have you pasted the cv2.pyd file in lib/site-packages folder?

  • i have also tried to import cv2 package in command line.it is executing there but when doing in the python idle ,it is not working. yes ,i have pasted cv2.pyd file in site package – Aj_kumar Jan 27 '18 at 20:01
  • you should then try to install using pip install command. Maybe some wheel file might be missing. – teago teego Jan 29 '18 at 04:00