I went to read up the syntax of cv2.imread() method and it says that specifying the flag=0 will load the image in grayscale.
The original image is this:
And I executed the following code with the following libs, no errors.
import cv2
import pytesseract
import matplotlib
import image
img=cv2.imread("C:/Users/HP_Demo/Desktop/cv2/sample02.png",0)
plt.imshow(img)
plt.show()
The result is this: Result image
import cv2
img=cv2.imread("colorful.png",1)
cv2.imshow("",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Result:
import cv2
img=cv2.imread("colorful.png",0) # same image changed the 1 to 0
cv2.imshow("",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Result:
Conclusion
As I said in a comment maybe the image you used is causing the no grayscale.