树莓派 Tkinter 通过 shh 和 xming [英] Raspberry Pi Tkinter via shh and xming

查看:68
本文介绍了树莓派 Tkinter 通过 shh 和 xming的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 ssh 客户端和 xming 从树莓派运行 Tkinter 脚本.通过 shh 登录 pi 后,我使用以下命令:

I'm trying to run a Tkinter script from a raspberry, via an ssh client and xming. Once I've logged into the pi via shh I use the command:

gksudo python3 home/pi/PythonScripts/TkinterTest.py

这是在我的电脑上给出的错误:

This is the error that is given on my PC:

(gksudo:2700): Gtk-WARNING **: cannot open display:

在我的笔记本电脑上运行相同的软件时出现不同的错误:

and a different error on my laptop running the same software:

(gksudo:3227): GLib-CRITICAL **: g_str_has_prefix: assertion 'str != NULL' failed

我尝试使用以下命令更改显示:

I have tried to change the display with the command:

export DISPLAY=:0.0    

但这对输出没有影响.

推荐答案

  1. 首先确保X转发在您的树莓派上处于活动状态,您可以在/etc/ssh/sshd_config中检查:X11Forwarding yes
  2. ssh -X username@(X11 转发的 -X 标志)
  3. 运行你的脚本:(su) python/path/to/script.py
  1. First of all be sure that the X forwarding is actived on your raspberry, you can check that in /etc/ssh/sshd_config: X11Forwarding yes
  2. ssh -X username@<raspberry> (-X flag for the X11 forwarding)
  3. Run your script : (su) python /path/to/script.py

有时当您尝试通过 sudo 运行程序时会出现一些错误,您需要检查 .Xauthority 文件的权限

Sometimes when you try to run program via sudo you can have some error, you need to check the permissions of .Xauthority file

这篇关于树莓派 Tkinter 通过 shh 和 xming的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆