You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
error: (-2:Unspecified error) Can't initialize GTK backend in function 'cvInitSystem' #18461
Everything compiles just fine until I run the program, an error like this appears:
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.12-pre) /media/sd/nam-detect/edgetpu-detection-camera/build/opencv/modules/highgui/src/window_gtk.cpp:624: error: (-2:Unspecified error) Can't initialize GTK backend in function 'cvInitSystem'
Aborted
libgtk2 is definitely installed:
$ sudo apt search libgtk2.0-dev
Sorting... Done
Full Text Search... Done
libgtk2.0-dev/eagle,now 2.24.32-3 arm64 [installed]
development files for the GTK+ library
Check Internet about gtk_init_check() call failure reasons.
We are only seeing this behavior on one of the system o_0
We don't help with remote investigation of problems which we are not able to reproduce on our side (because it is very time consuming and usually configuration problem without any following fix into OpenCV), but we can take a look on the clear reason of the problem and suggest some fix/workaround.
I managed to solve it by making sure when I ssh into aarch64 that I use ssh -Y user@host. This gives authorization to allow cv2.imshow() to display the window. gtk_init_check error solved
hope that helps
Reacted by Paul Niu, Wwupup, Syed Kausain Mehdi, devimy, Chad Smith, Ivan Matoshchuk, GQS, Felipe Rezende, Andrey Zakharoff, haixiansheng and 27 more
Reacted by Vilas Kaware, Alexander Viala Bellander, yamelakalemu, SiyaSalekar, Simesh Chaudhari, 如是说 and Xiguaren19
I managed to solve it by making sure when I ssh into aarch64 that I use ssh -Y user@host. This gives authorization to allow cv2.imshow() to display the window. gtk_init_check error solved
hope that helps
I solved the problem through this method. There is no GUI on the server side, so I need to comment out imshow.
I managed to solve it by making sure when I ssh into aarch64 that I use ssh -Y user@host. This gives authorization to allow cv2.imshow() to display the window. gtk_init_check error solved
hope that helps
So I encounter same problem.
"Can't initialize GTK backend in function 'cvInitSystem'". In my case I use Docker container and that error appears when I run OpenVino demo from docker. The problem is X11 server for the images or GUI server.You need install and run that server in Docker container. Running have to be when you start Docker container. In my case
I also had the same issue when running inside of a docker container. To fix the issue and gain access to the X server and the display I found this tutorial very helpful.
I managed to solve it by making sure when I ssh into aarch64 that I use ssh -Y user@host. This gives authorization to allow cv2.imshow() to display the window. gtk_init_check error solved hope that helps
I had to comment imshow() and also corresponding namedWindow() created for imshow(). Then my issue is resolved.
I faced same problem with OpenCV 4.7
If you use SSH to connect you divice or your progress is a server ,and nowhere to display any image.So please remove the code related windows or display.for example imshow()
I still have the problem. I am not doing ssh or using vnc. It's a rpi4 and the cv2.imshow function works fine if i run the script myself but when i do it via crontab or rc.local during boot then i see the error "can't initialize gtk backend in function 'cvinitsystem'"
Activity
BoShaoLi commentedon Oct 29, 2020
I have the same question. Did you solve the problem?
Namburger commentedon Oct 29, 2020
@15927495612 nope, no words from the team, unfortunately :/
BoShaoLi commentedon Oct 29, 2020
嘤嘤嘤~
IstiakFahim28 commentedon Nov 1, 2020
Facing same error. Please solve this issue....
alalek commentedon Nov 1, 2020
Check Internet about
gtk_init_check()call failure reasons.We don't help with remote investigation of problems which we are not able to reproduce on our side (because it is very time consuming and usually configuration problem without any following fix into OpenCV), but we can take a look on the clear reason of the problem and suggest some fix/workaround.
cassidylinhares commentedon Nov 6, 2020
I managed to solve it by making sure when I ssh into aarch64 that I use ssh -Y user@host. This gives authorization to allow cv2.imshow() to display the window.
gtk_init_check error solved
hope that helps
zjdx1998 commentedon Nov 28, 2020
Anything update? I encounter this error when I try the cpp-examples in the WSL ubuntu. Hope you could fix it soon.
n-gineer commentedon Dec 23, 2020
To help others, I found that my .bashrc needed to contain the following:
export DISPLAY=:0.0previously, it said
export DISPLAY=localhost:0.0Wwupup commentedon Jan 12, 2021
I solved the problem through this method. There is no GUI on the server side, so I need to comment out imshow.
hcgfighting commentedon Apr 8, 2021
this method is effective
w4w4n78 commentedon Apr 13, 2021
I tried this on Ubuntu 20.04 but still no luck
TVI-BIZ commentedon Apr 20, 2021
So I encounter same problem.
"Can't initialize GTK backend in function 'cvInitSystem'". In my case I use Docker container and that error appears when I run OpenVino demo from docker. The problem is X11 server for the images or GUI server.You need install and run that server in Docker container. Running have to be when you start Docker container. In my case
docker run --privileged -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -u 0 --device /dev/dri:/dev/dri --device-cgroup-rule='c 189:* rmw' -v /dev/bus/usb:/dev/bus/usb --rm openvino/ubuntu18_dev:update_1904
may be that command have some redundant stuff but works for me.My container base on official Intel container - https://hub.docker.com/r/openvino/ubuntu18_dev
chrjen commentedon Jun 8, 2021
I also had the same issue when running inside of a docker container. To fix the issue and gain access to the X server and the display I found this tutorial very helpful.
http://wiki.ros.org/docker/Tutorials/GUI
erdemozc commentedon Jun 25, 2021
hey guys. I am getting this error on navio2. does anyone know the solution?
reunanen commentedon Sep 30, 2021
For what it's worth, I'm using
xvfb-run -a <my program>.4 remaining items
scipioni commentedon Jul 7, 2022
this mapping -v /tmp/.X11-unix:/tmp/.X11-unix solved for me
phelix001 commentedon Oct 4, 2022
If you're running headless, you will probably get this error.
Can't initialize GTK backend in function 'cvInitSystem'
Solution :
ssh -Y user@wherever
I'm not sure how I will overcome this issue when running opencv as a service. Perhaps just get rid of imshow.
liuzihaode commentedon Oct 17, 2022
thank u, your answer solved my problem
bitorangej commentedon Feb 8, 2023
it works!
kartikpodugu commentedon Apr 11, 2023
I had to comment imshow() and also corresponding namedWindow() created for imshow(). Then my issue is resolved.
I faced same problem with OpenCV 4.7
phelix001 commentedon Apr 11, 2023
The keyword here is headless install. If headless install and getting the cv2.imshow() error, then use the -Y flag on ssh
sunbeam-217 commentedon May 16, 2023
If you use SSH to connect you divice or your progress is a server ,and nowhere to display any image.So please remove the code related windows or display.for example imshow()
anvinder commentedon May 25, 2023
I still have the problem. I am not doing ssh or using vnc. It's a rpi4 and the cv2.imshow function works fine if i run the script myself but when i do it via crontab or rc.local during boot then i see the error "can't initialize gtk backend in function 'cvinitsystem'"
Nandu3219 commentedon Aug 10, 2023
solve me ,for raspberrpi 4 terminal window
arielkantorovich commentedon Nov 14, 2023
You succeed to slove this problem to WSL?
ramanrewati commentedon Jun 7, 2024
It happens to me while running yolov4 using darknet inferencing on videos. Does it have a fix yet?
rbgreenway commentedon Aug 5, 2024
My fix was to run the command:
xhost +from a terminal outside the docker container
Nickiris commentedon Aug 31, 2024
I have solved this problem in WSL ubuntu
this may help: https://mikailuos.com/2021/08/19/Games101/%E7%AC%AC%E9%9B%B6%E7%AF%87-WSL-Cmake-Opencv%E7%9A%84%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/
shfunc commentedon Nov 19, 2024
this helps me:
from host machine:
from ssh machine:
alaingautherot commentedon Feb 12, 2025
If running docker, you may need
xhost +local:dockerlike so: