1 import numpy as np
2 import cv2
3 import matplotlib.pyplot as plt
4 %matplotlib inline # if you are running this code in jupyter notebook
5
6 img = cv2.imread('/path_to_image/opencv-logo.png',0) # reads image 'opencv-logo.png' as grayscale
7 plt.imshow(img, cmap='gray')
1//There is no such code to fix this problem.
2//Usually cv2.imread(path) does not load image when the path is invalid.
3//Make sure your path is correct and try again :)