嗨,我是硒自动化的新手。
我编写的代码可以正常工作,并且可以在pycharm和命令提示符下执行,但是当我尝试从远程服务器执行相同的代码时,出现以下错误。
我理解它与使用Pynput一样,但是我不知道该如何解决。 如果有人知道,请帮助我。
File "/home/manoj/forum-test-suite/test_forum_page/PageObject/common_methods.py", line 6, in <module>
from pynput.keyboard import Key,Controller
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/__init__.py", line 23, in <module>
from . import keyboard
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/keyboard/__init__.py", line 49, in <module>
from ._xorg import KeyCode, Key, Controller, Listener
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/keyboard/_xorg.py", line 39, in <module>
from pynput._util.xorg import (
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/_util/xorg.py", line 40, in <module>
_check()
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/_util/xorg.py", line 38, in _check
display = Xlib.display.Display()
File "/home/manoj/newenv/lib/python3.6/site-packages/Xlib/display.py", line 89, in __init__
self.display = _BaseDisplay(display)
File "/home/manoj/newenv/lib/python3.6/site-packages/Xlib/display.py", line 71, in __init__
protocol_display.Display.__init__(self, *args, **keys)
File "/home/manoj/newenv/lib/python3.6/site-packages/Xlib/protocol/display.py", line 167, in __init__
raise error.DisplayConnectionError(self.display_name, r.reason)
答案 0 :(得分:0)
问题是关于pynput的,您需要转到.bashprofile并附加 Pyput路径,在您设置的PYTHONPATH中。通过这样做,我能够解决此问题。