pkexec 显示图像界面
如果按照正常使用 pkexec
的方法来使用:
pkexec ls /
没问题,但运行图形程序:
gfdgd_xi@gfdgd-xi-PC:~$ pkexec /home/gfdgd_xi/Documents/git/uengine-runner/main.py Traceback (most recent call last): File "/home/gfdgd_xi/Documents/git/uengine-runner/main.py", line 609, in <module> win = tk.Tk() # 创建窗口 File "/usr/lib/python3.7/tkinter/__init__.py", line 2023, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)_tkinter.TclError: no display name and no $DISPLAY environment variable
解决方法如下:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY XXX # XXX 为命令
赞 (0)