Xlib.error.DisplayConnectionError on Ubuntu 18.04
See original GitHub issueImporting pyautogui in Python 3.7.2 in Ubuntu 18.04, generates a Xlib.error.DisplayConnectionError This error only occurs when running python with superuser privileges.
This the full traceback :-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/pyautogui/__init__.py", line 152, in <module>
from . import _pyautogui_x11 as platformModule
File "/usr/local/lib/python3.7/site-packages/pyautogui/_pyautogui_x11.py", line 160, in <module>
_display = Display(os.environ['DISPLAY'])
File "/usr/local/lib/python3.7/site-packages/Xlib/display.py", line 89, in __init__
self.display = _BaseDisplay(display)
File "/usr/local/lib/python3.7/site-packages/Xlib/display.py", line 71, in __init__
protocol_display.Display.__init__(self, *args, **keys)
File "/usr/local/lib/python3.7/site-packages/Xlib/protocol/display.py", line 167, in __init__
raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'No protocol specified\n
Steps to reproduce:-
- run
sudo python3
in the terminal - run
import pyautogui
inside the python 3 shell
Issue Analytics
- State:
- Created 4 years ago
- Comments:9
Top Results From Across the Web
How to fix error Xlib.error.DisplayConnectionError: Can't ...
On my PC with Ubuntu 14.04 everything works fine but when I try to run my app in my notebook with manualy installed...
Read more >Python Xlib applications report 'Can't connect to display ":0"
Bug Description. The python-xlib package does not appear to correctly use X11 cookies from $XAUTHORITY under Ubuntu 18.04 (and possibly others).
Read more >python-xlib - Bountysource
DisplayConnectionError (dname, str(val)) Xlib.error. ... I was writing an automation script on Ubuntu 18.04 using python-xlib when I noticed that keycode ...
Read more >Linux multiple monitor error? (with shaky workaround) - Support
Hi there, I tried to get AW to run on my Ubuntu 18.04 (Macbook Pro hardware), but I got this error repeatedly: 2018-10-08...
Read more >xorg - How can I diagnose/debug "maximum number of clients ...
X11 -unix/X0 socket file; but there are lots more connections (displayed as ... Chromium/Chrome has some known issues which result in this error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try https://github.com/mooz/xkeysnail/blob/master/README.md (look at usage section)
worked for me.
ok, issue resolve by installing python-tk (not python3-tk), then restart terminal or system, then it works. As the installation guide, i did install acrot, python3-tk and python3-dev, but it turn out not working, I’m not sure if I had restarted terminal right after these packs install, but I did restart after python-tk, then everything work.
Not sure if both python3-tk and python-tk are needed, or just python-tk alone.