Python3.5 Xlib错误任何人都遇到了同样的问题?

时间:2016-11-27 20:31:47

标签: python-3.5 xlib display pyautogui

我正在尝试安装pyautogui。它有一些错误如下所示:

File "<pyshell#2>", line 1, in <module>
    display = Display()
  File "/usr/lib/python3.5/site-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/python3.5/site-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/usr/lib/python3.5/site-packages/Xlib/protocol/display.py", line 160, in __init__
    raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'No protocol specified\n'
然后我用Google搜索并发现一些专家发现了一些错误:

https://github.com/LiuLang/python3-xlib/issues/6 https://github.com/LiuLang/python3-xlib/issues/7

所以他们通过更改Xlib中的xauth.py代码来解决它。 当我跟着它时,它引发了另一个错误,如下所示:

  File "<pyshell#2>", line 1, in <module>
    display = Display()
  File "/usr/lib/python3.5/site-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/python3.5/site-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/usr/lib/python3.5/site-packages/Xlib/protocol/display.py", line 92, in __init__
    name, host, displayno)
  File "/usr/lib/python3.5/site-packages/Xlib/support/connect.py", line 101, in get_auth
    return mod.get_auth(sock, dname, host, dno)
  File "/usr/lib/python3.5/site-packages/Xlib/support/unix_connect.py", line 124, in new_get_auth
    return au.get_best_auth(family, addr, dno)
  File "/usr/lib/python3.5/site-packages/Xlib/xauth.py", line 112, in get_best_auth
    address = address.encode()
AttributeError: 'bytes' object has no attribute 'encode'
你见过类似的问题吗?或者是因为我的系统有问题?

(稍后编辑)

我只是尝试在python2.7.12中做所有事情我遇到了以下错误信息:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    display = Display()
  File "/usr/lib/python2.7/site-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/python2.7/site-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/usr/lib/python2.7/site-packages/Xlib/protocol/display.py", line 92, in __init__
    name, host, displayno)
  File "/usr/lib/python2.7/site-packages/Xlib/support/connect.py", line 101, in get_auth
    return mod.get_auth(sock, dname, host, dno)
  File "/usr/lib/python2.7/site-packages/Xlib/support/unix_connect.py", line 121, in new_get_auth
    au = xauth.Xauthority()
  File "/usr/lib/python2.7/site-packages/Xlib/xauth.py", line 47, in __init__
    raise error.XauthError('~/.Xauthority: %s' % err)
XauthError: ~/.Xauthority: [Errno 2] No such file or directory: '/home/rnie/.Xauthority'

你遇到过这个问题吗?默认情况下,.Xauthority应该在我的用户主目录下,对吧?我通过检查“cat~ / .Xauthority”找不到它。它没有说这样的文件:(

0 个答案:

没有答案