Import pautogui and KeyError: ‘display’

I have an app that runs fine in local host but when deploying I get error message

2021-12-15 01:22:56.871 Uncaught app exception
Traceback (most recent call last):
File “/home/appuser/venv/lib/python3.7/site-packages/streamlit/”, line 354, in _run_script
exec(code, module.dict)
File “/app/staygreen/”, line 28, in
import pyautogui as gui
File “/home/appuser/venv/lib/python3.7/site-packages/pyautogui/”, line 249, in
import mouseinfo
File “/home/appuser/venv/lib/python3.7/site-packages/mouseinfo/”, line 223, in
_display = Display(os.environ[‘DISPLAY’])
File “/usr/local/lib/python3.7/”, line 681, in getitem
raise KeyError(key) from None
KeyError: ‘DISPLAY’

Thanks for the help!

Same here. I am able to use pyautogui to print screenshot in my localhost but it doesn’t work in the streamlit app. Looks like streamlit is not accepting the pyautogui module.

Is there any other ways I can add a screenshot button in streamlit, since a report function hasn’t been developed yet?