我正在尝试通过VNC运行wxpython脚本。当我尝试打开它时,我收到错误:
由于身份验证错误,X11连接被拒绝。 无法访问X显示器,是否正确设置了$ DISPLAY?
我通过以下方式解决:
xauth list
sudo xauth add raspberrypi/unix:10 MIT-MAGIC-COOKIE-1
然后是相应的cookie。我想在脚本的init中自动执行此操作,以便用户不必每次都执行此操作。我写了以下脚本:
import subprocess
import string
p=subprocess.Popen(['xauth','list'],stdout=subprocess.PIPE)
(out,err)=p.communicate()
out1=out.split('\n')
for line in out1:
t=line.split()
y=subprocess.Popen(['sudo','xauth','add',t[0],t[1],t[2]],stdout=subprocess.PIPE)
工作正常,但我仍然无法让程序运行。检查输出我意识到如果我从shell运行xauth列表并且如果我用Popen运行它,我没有得到相同的输出。
非常感谢任何帮助!