question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError: 'DISPLAY' when installing pyautogui

See original GitHub issue

When I tried to install pyautogui with sudo pip3 install pyautogui I get the error info

pi@raspberrypi:~/Desktop/test/c_test $ sudo pip3 install pyautogui Downloading/unpacking pyautogui Downloading PyAutoGUI-0.9.36.tar.gz (46kB): 46kB downloaded Running setup.py (path:/tmp/pip-build-tbxln81q/pyautogui/setup.py) egg_info for package pyautogui Traceback (most recent call last): File “<string>”, line 17, in <module> File “/tmp/pip-build-tbxln81q/pyautogui/setup.py”, line 6, in <module> version=import(‘pyautogui’).version, File “/tmp/pip-build-tbxln81q/pyautogui/pyautogui/init.py”, line 115, in <module> from . import _pyautogui_x11 as platformModule File “/tmp/pip-build-tbxln81q/pyautogui/pyautogui/_pyautogui_x11.py”, line 160, in <module> _display = Display(os.environ[‘DISPLAY’]) File “/usr/lib/python3.4/os.py”, line 633, in getitem raise KeyError(key) from None KeyError: ‘DISPLAY’ Complete output from command python setup.py egg_info: Traceback (most recent call last):

File “<string>”, line 17, in <module>

File “/tmp/pip-build-tbxln81q/pyautogui/setup.py”, line 6, in <module>

version=__import__('pyautogui').__version__,

File “/tmp/pip-build-tbxln81q/pyautogui/pyautogui/init.py”, line 115, in <module>

from . import _pyautogui_x11 as platformModule

File “/tmp/pip-build-tbxln81q/pyautogui/pyautogui/_pyautogui_x11.py”, line 160, in <module>

_display = Display(os.environ['DISPLAY'])

File “/usr/lib/python3.4/os.py”, line 633, in getitem

raise KeyError(key) from None

KeyError: ‘DISPLAY’


Cleaning up… Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-tbxln81q/pyautogui Storing debug log for failure in /root/.pip/pip.log

I followed the install steps listed in the Docs(http://pyautogui.readthedocs.io/en/latest/install.html). Do anyone know why this happens and how to fix it? Thank you so much.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10

github_iconTop GitHub Comments

5reactions
curkychencommented, Jun 7, 2017

Have solved it. It is because of using ssh to install the package. When I install it by using the raspberrypi directly it solved.

0reactions
JeedHome44commented, Jan 16, 2022

Hello,

I do a mouse-reset.py like this for my magic mirror:

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import pyautogui
import time

while True:
    try:
        if pyautogui.position != (1918, 1078):
            time.sleep(0.1)
            pyautogui.moveTo(1918, 1078)
            time.sleep(0.1)
        time.sleep(0.1)
    except:
        time.sleep(0.1)

it’s work correctly when the mirror boot. but i need to pkill python when i want to power off the screen.

my problem: i can’t laucnh this in SSH: python3 /home/pi/programmes/mouse-reset.py

i have error display.

pyautogui test the client but not serveur display.

What i have to do to do this python program in SSH?

i test add it in a mouse.sh and do: bash /home/pi/scripts/mouse.sh but same problem: Error Display.

Please, i need help to activate this python program with SSH when i do bash /home/pi/scripts/ecran_on.sh

i want this program execute in ssh serveur, not in ssh client.

thank you for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

importing pyautogui in ubuntu throwing KEYERROR :DISPLAY
You have to correctly set environment variable DISPLAY . It should be defined by your OS. If it's not, you can define it...
Read more >
importing pyautogui in ubuntu throwing KEYERROR :DISPLAY
You have to correctly set environment variable DISPLAY . It should be defined by your OS. If it's not, you can define it...
Read more >
Import pywhatkit and KeyError: 'display' - Streamlit
My app runs fine in local host, but when deploying I got this error message: Thanks for your help!
Read more >
Installation - PyAutoGUI documentation - Read the Docs
To install PyAutoGUI, install the pyautogui package from PyPI by running pip install pyautogui (on Windows) or pip3 install pyautogui (on macOS and...
Read more >
Developers - Windows KeyError: 'DISPLAY' - - Bountysource
Windows KeyError: 'DISPLAY'. pyautogui. 30 March 2021 Posted by medoix. I am following the documentation to install pyautogui on Windows. Installed via
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found