python-3.x - 通过Shh和Xming的Raspberry Pi Tkinter

标签 python-3.x ssh tkinter raspberry-pi

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

gksudo python3 home/pi/PythonScripts/TkinterTest.py

这是我的电脑上给出的错误:
(gksudo:2700): Gtk-WARNING **: cannot open display:

并且在运行相同软件的笔记本电脑上出现了另一个错误:
(gksudo:3227): GLib-CRITICAL **: g_str_has_prefix: assertion 'str != NULL' failed

我尝试使用以下命令更改显示:
export DISPLAY=:0.0    

但这对输出没有影响。

最佳答案

  • 首先,确保树莓派上已启用X转发的,您可以在/etc/ssh/sshd_config中进行检查:X11Forwarding yes
  • ssh -X username@<raspberry>(X11转发的-X标志)
  • 运行脚本:(su) python /path/to/script.py

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

    关于python-3.x - 通过Shh和Xming的Raspberry Pi Tkinter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29593245/

    相关文章:

    python - 类 A 方法中类型 A 参数的类型提示

    linux - SSH 并在脚本中运行命令

    java - 如何使用java在没有密码的情况下ssh到主机

    python - Tkinter keyrelease 事件插入新行,而按键则不插入新行

    python - Tkinter 警告消息中的 "do not show message again"复选框

    python - 使用 Tkinter 控制回调顺序

    python - 使用 Python 3.7 导入 pyobjc AppKit 时如何消除不需要的调试输出

    python - GIL 是否会影响单独终端窗口中 python 脚本的并行处理?

    jenkins - 如何从Jenkins的Windows机器在远程linux机器中启动脚本?

    c# - 在 Python ReST 文档字符串中是否有类似 C#'s "see cref"的内容?