How to fix error Xlib.error.DisplayConnectionError: Can't connect to display “:0”: b'No protocol specified\n'

﹥>﹥吖頭↗ 提交于 2021-02-06 10:46:50

问题


I'm making some program with python3 and XLib.

On my PC with Ubuntu 14.04 everything works fine but when I try to run my app in my notebook with manualy installed Xorg I get exception:

Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'No protocol specified\n'

on line:

self.__display = Xlib.display.Display()

What's going on here? How to fix this that it could work on every Linux?

Edit:

This does not look like duplicate of X11: run a gnome app as another user. On my both computers I have same users and groups, so this problem is probably not connected with lack of permissions to run my program.

It must be something else something with bad configuration of X.


回答1:


Temporary workaround is

$ xhost +

http://ubuntuforums.org/showthread.php?t=2290602




回答2:


Ok, It was bug in python3-xlib. See https://github.com/LiuLang/python3-xlib/issues/6 for details.



来源:https://stackoverflow.com/questions/31902846/how-to-fix-error-xlib-error-displayconnectionerror-cant-connect-to-display-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!