My Code is
import numpy as np
import cv2 as cv
img = cv.imread('img.jpg',0)
cv.imshow('image',img)
cv.waitKey(0)
cv.destroyAllWindows()
And the error is
Traceback (most recent call last):
File "opencv.py", line 5, in <module>
cv.imshow('image',img)
cv2.error: OpenCV(3.4.2) /tmp/build/80754af9/opencv-suite_1535558553474 /work/modules/highgui/src/window.cpp:632: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
Install the two missing dependency packages. In all currently supported versions of Ubuntu open the terminal and type:
The Python code in the question runs successfully in Ubuntu 18.04 after installing these packages. The packages that I have installed all came from the default Ubuntu 18.04 repositories.