Environment variable DISPLAY is empty
-
Hi there!
I wanted to do a kind of TAS for retropie and I'm stuck on an issue that I don't know how to solve.
Here my install log
sudo apt-get install python3-pip
sudo apt-get install python3-xlib
sudo pip3 install pyautoguiThen I tried to launch a python Script through :
sudo python3 /home/pi/RetroPie/test.py
Traceback (most recent call last):
File "test.py", line 22, in <module>
import pyautogui
File "/usr/local/lib/python3.5/dist-packages/pyautogui/init.py", line 115, in <module>
from . import _pyautogui_x11 as platformModule
File "/usr/local/lib/python3.5/dist-packages/pyautogui/_pyautogui_x11.py", line 160, in <module>
_display = Display(os.environ['DISPLAY'])
File "/usr/lib/python3.5/os.py", line 725, in getitem
raise KeyError(key) from None
KeyError: 'DISPLAY'I googled and found : https://stackoverflow.com/questions/49308345/how-to-fix-keyerror-display-in-python
Which means there is no Display (echo $DISPLAY is empty)
Why? Can I set one ? If someone knows... I would be happy to understand and learn!
-
@teclisb RetroPie does not use an X11 environment when running on a Raspberry Pi and your program seems to need one in order to run. Only when installed on a PC, RetroPie runs from an X server session.
Since you didn't add any of the info requested in https://retropie.org.uk/forum/topic/3/read-this-first, I'm not sure if this is the problem, but if you're trying to run this on a PI, then it won't work and you have to find a solution that doesn't need an X11 server started. -
Pi Model or other hardware: Pi3
Power Supply used: Yes and working well
RetroPie Version Used (eg 3.6, 3.8.1, 4.1 - do not write latest): 4.4
Built From: (Pre made SD Image on RetroPie website, Berryboot, or on top of existing OS etc.. - please provide the filename of any image used) : retropie-4.4-rpi2_rpi3.img
USB Devices connected: XBOX360 Controller
Controller used: XBOX360 Controller
Error messages received: Previous message
Log found in /dev/shm/runcommand.log (if relevant): Not relevant
Guide used: (Mention if you followed a guide) None
File: (File with issue - with FULL path) None
Emulator: (Name of emulator - if applicable) None
Attachment of config files: (PLEASE USE PASTEBIN.COM FOR LARGE LOGS) None
How to replicate the problem: follow the previous installation and launch a python script using pyautoguiSadly pyautogui needs a X11, I tried the script on windows and it's working.
Is there a way to start an X11 server and keep emulators working ? -
@teclisb said in Environment variable DISPLAY is empty:
Is there a way to start an X11 server and keep emulators working ?
Only if you install RP on a PC, as I said before. Almost all emulators on the Pi version don't run on X, with some notable exceptions (mainly Ports).
-
Ok I see... So it's possible to use my script and retropie However, only on a computer.
Thanks for the information I wasn't aware that on RP almost all emulators don't run on X.Thanks a lot :)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.