Reputation: 19
I want to automate a windows task and from searching the web PyAutoGui seems to be the right tool for it. Im working on a virtual env , using python 3.6.9, and a ubuntu WSL. after installing it with :
pip install pyautogui
I get this error after importing
>>> import pyautogui Traceback (most recent call last): File "", line 1, in File "/mnt/c/GitHub/dad/project_env/lib/python3.6/site-packages/pyautogui/__init__.py", line 241, in import mouseinfo File "/mnt/c/GitHub/dad/project_env/lib/python3.6/site-packages/mouseinfo/__init__.py", line 223, in _display = Display(os.environ['DISPLAY']) File "/usr/lib/python3.6/os.py", line 669, in __getitem__ raise KeyError(key) from None KeyError: 'DISPLAY'
after few failing attempts I`ve tried installing PyWin as well , and got another kind of error. I also tried to define
`DISPLAY=:0 python`
but still failed.
Upvotes: 1
Views: 3958
Reputation: 28
This error occurs while you try to execute in a terminal with no interface, you need to point to a interface inside your system.
You can locate a session by:
ps aux
and execute your script pointing to your interface like:
python3.9 main.py -- :1 vt7
Upvotes: 0