Skip to content

fix: Handle undefined DISPLAY environment variable for pyautogui (#1552)#1681

Closed
majiayu000 wants to merge 1 commit intoopeninterpreter:mainfrom
majiayu000:fix/1552-handle-missing-display-env
Closed

fix: Handle undefined DISPLAY environment variable for pyautogui (#1552)#1681
majiayu000 wants to merge 1 commit intoopeninterpreter:mainfrom
majiayu000:fix/1552-handle-missing-display-env

Conversation

@majiayu000
Copy link
Copy Markdown

Describe the changes you have made:

When DISPLAY is not set (e.g., SSH sessions without X11 forwarding), pyautogui import fails with KeyError: 'DISPLAY'. This commit adds graceful error handling:

  • Wrap pyautogui imports in try/except blocks in computer.py and loop.py
  • Use fallback screen size (1024x768) when pyautogui unavailable
  • Raise clear ToolError when computer tool is actually used without display
  • Skip mouse position checking thread when no display attached
  • Add pytest skip for display-dependent tests on Linux without DISPLAY
  • Add unit tests for DISPLAY handling (test_display_env.py)

Reference any relevant issues (e.g. "Fixes #000"):

Fixes #1552

Pre-Submission Checklist (optional but appreciated):

  • I have included relevant documentation updates (stored in /docs)
  • I have read docs/CONTRIBUTING.md
  • I have read docs/ROADMAP.md

OS Tests (optional but appreciated):

  • Tested on Windows
  • Tested on MacOS
  • Tested on Linux

…ninterpreter#1552)

When DISPLAY is not set (e.g., SSH sessions without X11 forwarding),
pyautogui import fails with KeyError: 'DISPLAY'. This commit adds
graceful error handling:

- Wrap pyautogui imports in try/except blocks
- Use fallback screen size when pyautogui unavailable
- Raise clear ToolError when computer tool is actually used
- Skip mouse position checking thread when no display
- Add pytest skip for display-dependent tests on Linux without DISPLAY
- Add unit tests for DISPLAY handling

Fixes openinterpreter#1552

Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000
Copy link
Copy Markdown
Author

Closing this PR due to extended inactivity. Happy to reopen if there's still interest — feel free to comment.

@majiayu000 majiayu000 closed this Mar 20, 2026
@endolith
Copy link
Copy Markdown
Contributor

No need to close it, the maintainers are just busy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the DISPLAY environment variable can be undefined

2 participants