Reputation: 8173
I have a Python script, which displays images on a projector without user interaction. It calls OpenCV functions, which are using GTK backend. It runs just fine locally. When I try to run it remotely with ssh
, I'm getting Can't initialize GTK backend
error:
cv2.error: OpenCV(4.5.3) /tmp/pip-wheel-xjhn4aom/opencv-contrib-python_db9bf2c2b8dd41b592a48d20aac72627/opencv/modules/highgui/src/window_gtk.cpp:635: error: (-2:Unspecified error) Can't initialize GTK backend in function 'cvInitSystem'
What is the way to fix it? I don't want to see the images on the client. I want the host to display images exactly the same way as if the script was run locally.
Upvotes: 0
Views: 1781
Reputation: 28868
This probably because the server you are ssh'ing into has no X installed (the graphical environment). Check if you have an environment variable called DISPLAY on this server. If X is running on this server, you have to set your SSH sessions display to match the number of the running display. Hopefully, this helps...
See also here https://unix.stackexchange.com/questions/10121/open-a-window-on-a-remote-x-display-why-cannot-open-display
Upvotes: 1