无法打开设置了 python 子进程和 DISPLAY 和 XAUTHORITY 变量的 X 显示
Unable to open X display with python subprocess and DISPLAY and XAUTHORITY variables set
我正在尝试从 python systemd 服务启动消息框,该服务是 运行 根用户。
subprocess.Popen(["/usr/bin/zenity", "--info", "--text", "please reboot for changes to take effect"], env=dict(os.environ, DISPLAY="0.0", XAUTHORITY="/home/pi/.Xauthority"))
我已经设置了环境变量 DISPLAY 和 XAUTHORITY,但是我仍然收到连接被拒绝的消息
** (zenity:5491): WARNING **: Could not open X display
Unable to init sever: Could not connect: Connection refused
(zenity:5491): Gtk-WARNING **: cannot open display: 0.0
这里有什么我遗漏的吗?
很可能是由于 DISPLAY env var 中的值不正确。试试 DISPLAY = ":0.0"
subprocess.Popen(["/usr/bin/zenity", "--info", "--text", "please reboot for changes to take effect"], env=dict(os.environ, DISPLAY=":0.0", XAUTHORITY="/home/pi/.Xauthority"))
我正在尝试从 python systemd 服务启动消息框,该服务是 运行 根用户。
subprocess.Popen(["/usr/bin/zenity", "--info", "--text", "please reboot for changes to take effect"], env=dict(os.environ, DISPLAY="0.0", XAUTHORITY="/home/pi/.Xauthority"))
我已经设置了环境变量 DISPLAY 和 XAUTHORITY,但是我仍然收到连接被拒绝的消息
** (zenity:5491): WARNING **: Could not open X display
Unable to init sever: Could not connect: Connection refused
(zenity:5491): Gtk-WARNING **: cannot open display: 0.0
这里有什么我遗漏的吗?
很可能是由于 DISPLAY env var 中的值不正确。试试 DISPLAY = ":0.0"
subprocess.Popen(["/usr/bin/zenity", "--info", "--text", "please reboot for changes to take effect"], env=dict(os.environ, DISPLAY=":0.0", XAUTHORITY="/home/pi/.Xauthority"))