This is the exact error that I am getting. My OS is Ubuntu 16.10.
OpenCV Error: 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 cvShowImage, file /feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp, line 545 Traceback (most recent call last): File "untitled.py", line 7, in cv2.imshow('image',img) cv2.error: /feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp:545: error: (-2) 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
my code is:
import numpy as np
import cv2
# Load an color image in grayscale
img = cv2.imread('0002.png',0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
0002.png is an image in the same directory as the program. I first installed anaconda with python 3.5, then I installed opencv by using the command
conda install -c conda-forge opencv
I installed libgtk2.0-dev just as the error said to but I still get the same error. Any help would be much appreciated. I've been trying to solve this for several hours.
1.The easiest way:
or (for OpenCV 3.1) :
2.And if u don't want to do this, you can try to use matplotlib .
3.Or try to build library by your own with option
WITH_GTK=ON
, or smth like that.Update - 18th Jun 2019
I got this error on my Ubuntu(18.04.1 LTS) system for openCV 3.4.2, as the method call to cv2.imshow was failing. I am using anaconda. Just the below 2 steps helped me resolve:
If you are using pip, you can try
Although this is already answered, for me conda-forge solution worked with a hack. My workstation is a centos 6 machine, and I use conda virtual environment (anaconda 2). Create an environment
and then activate it
Now install opencv from conda-forge
Now install matplotlib in this environment (and this is hack 1)
Let's check now imshow works or not. In a terminal, activate test environment and start python. In the interpreter, do
This should pop up a window showing image. I did not further research how this solved the case.
Note 1: You may see some error related to xkb, then in your .bashrc file add
export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb
Note 2: You may see some error related to XDG_RUNTIME_DIR, then in your .bashrc file also add
export XDG_RUNTIME_DIR=.tmp/myruntime and define myruntime by mkdir -p .tmp/myruntime
I have had to deal with this issue a couple of times, this is what has worked consistently thus far:
I used pip to install opencv-python. (https://pypi.org/project/opencv-python/)
1) Remove the opencv package from conda:
2) To your env.yml file add this:
Notice that it is complaining for libgtk2.0-dev and pkg-config. Here is the solution. Uninstall your existing openCV installation.
conda remove opencv3
Install these packages before installing opencv- conda install gtk2 pkg-config
Now install opencv from menpo conda install -c https://conda.anaconda.org/menpo opencv3