OpenCV imread AttributeError: partially initialized module 'cv2' has no attribute 'imread

319 views Asked by At

I am trying to use the cv2.imread() function to read an image file in Python using OpenCV, but I am encountering an AttributeError with the message "partially initialized module 'cv2' has no attribute 'imread'". I have installed the OpenCV library and imported the cv2 module correctly in my Python script, but I am still encountering this error. Here is my code:

import cv2
img = cv2.imread(r'img.png')
cv2.imshow('img', img)
cv2.waitKey()
cv2.destroyAllWindows()

I have created a simple Python script with only the code above. When I run the script, I get the following error message: AttributeError: partially initialized module 'cv2' has no attribute 'imread' (most likely due to a circular import)

0

There are 0 answers