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!