Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 通过shh和xming的树莓皮_Python 3.x_Ssh_Tkinter_Raspberry Pi - Fatal编程技术网

Python 3.x 通过shh和xming的树莓皮

Python 3.x 通过shh和xming的树莓皮,python-3.x,ssh,tkinter,raspberry-pi,Python 3.x,Ssh,Tkinter,Raspberry Pi,我正试图通过ssh客户端和xming从raspberry运行Tkinter脚本。通过shh登录pi后,我使用以下命令: gksudo python3 home/pi/PythonScripts/TkinterTest.py 这是我的电脑上给出的错误: (gksudo:2700): Gtk-WARNING **: cannot open display: 在运行相同软件的笔记本电脑上出现不同的错误: (gksudo:3227): GLib-CRITICAL **: g_str_has_pref

我正试图通过ssh客户端和xming从raspberry运行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
    中检查:
    X11正向是
  • ssh-X username@
    (-X标志用于X11转发)
  • 运行脚本:
    (su)python/path/to/script.py

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

    我遇到了类似的问题。我知道这个问题已经问了三年了。但我的搜索把我带到了这里。那么就回答这个问题吧

    sudo cp ~pi/.Xauthority ~root/
    
    这只是将X11授权文件直接复制到root,而无需xauth命令管理。这将使所有活动用户pi X11连接都可供root用户使用,而无需进行排序并找到正确的连接

    附言:我只是复制粘贴,功劳归我