How i solve this error?

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'
3

1 Answer

Install the two missing dependency packages. In all currently supported versions of Ubuntu open the terminal and type:

sudo apt update
sudo apt install libgtk2.0-dev pkg-config python3-opencv 

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.

  • python3 - version 3.6
  • python3-numpy
  • python3-opencv
  • libgtk2.0-dev
  • pkg-config
10

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like