locateOnScreen on Ubuntu Linux no longer working
Author: tsmasterCreated Jun 3, 2026Updated Jun 3, 2026
I just updated my Ubuntu machine to 26.04, and a pyautogui script that I've been using is now failing with the following error output:
** Message: 08:03:58.135: Unable to use GNOME Shell's builtin screenshot interface, resorting to fallback X11.
(gnome-screenshot:17621): Gdk-CRITICAL **: 08:03:58.135: gdk_pixbuf_get_from_surface: assertion 'width > 0 && height > 0' failed
(gnome-screenshot:17621): GdkPixbuf-CRITICAL **: 08:03:58.135: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed
(gnome-screenshot:17621): GdkPixbuf-CRITICAL **: 08:03:58.135: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed *** BUG *** In pixman_region32_init_rect: Invalid rectangle passed Set a breakpoint on '_pixman_log_error' to debug
the code I'm running looks like
loc = pyautogui.locateOnScreen(FILENAME, region=(0, 0, scr_x, scr_y))
Source: asweigart/pyautogui