asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.47k stars 1.27k forks source link

Cannot even import the library if X11 is not available #893

Open SamStephens opened 2 days ago

SamStephens commented 2 days ago

I have an application that uses pyautogui that I've been asked to modify so that it doesn't use pyautogui for certain use cases where it's not required (getting more specific than this would be quite verbose).

The problem that I'm facing is import pyautogui fails with the error

XauthError: ~/.Xauthority: [Errno 2] No such file or directory: '/home/sam/.Xauthority'

if X11 is not available.

I'd argue this failure should not occur at import time; it should occur when attempts to actually use pyautogui functionality are made.

See also https://github.com/asweigart/pyautogui/issues/111