需求
树莓派上运行的操作系统是lite版本(无桌面),但开发过程中用到了GUI界面调试,需要把树莓派运行的GUI在PC机上显示出来。
树莓派3B+ Linux raspberrypi 5.4.83-v7+
window 10
参考连接
实现思路
X server是Linux系统里面图形接口bai服务器的简称。Windows系统的界面是这个系统不可分割的一部分,各种窗口操作界面显示都是由系统核心直接管理的,而Linux的图形界面并不是系shu统的必要组成部分,它可以在无界面的条件下运行。当需要Linux提供界面的时候,系统就会建立一个或者数个X server,通过X协议跟窗口管理器交互,由独立于系统的应用程序来产生窗口,状态栏,按钮之类的交互界面。
比较常见的Linux界面操作环境有KDE和GNOME,为它们提供系统支持的就是X server,而并非Linux核心。总结一下linux图形界面层次关系:linux本身-->X服务器<-[通过X协议交谈]->窗口管理器(综合桌面环境)-->X应用程序。
这里不需要树莓派的桌面环境,只需要安装X server就好。win10下也需要安装X server软件,这里选择VcXsrv(一个好用的开源免费的win的X server)。
步骤
1、切换树莓派的源:参考 树莓派—raspbian软件源
2、树莓派上安装xorg:
sudo apt-get install xserver-xorg
sudo apt-get install xinit
3、win10安装 VcXsrv
下载链接 https://sourceforge.net/projects/vcxsrv/
4、安装putty
... ...
5、使用ssh连接到服务器, 把服务器的X请求转发到本地的 X server
vi /etc/ssh/sshd_config
AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
6、WIN10上设置vcxsrv,点击xlaunch.exe
7、在本地win机上启动putty,配置转发X11的会话
8、打开ssh,测试链接是否成功
sudo apt install x11-apps -y && xeyes
9、遇到问题及解决
PuTTY X11 proxy: Unsupported Authorisation Protocol [closed]
While logged in as su, after a few "PuTTY X11 proxy: wrong authorisation protocol attempted", and "PuTTY X11 proxy: Unsupported authorisation protocol" -type errors, I realized it was an authentication problem. I then remembered to copy the .Xauthority file from my own profile /home directory to /root. Problem solved!
使用matplotlib时出现问题
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend
https://blog.youkuaiyun.com/qq_41073715/article/details/105033751
安装tkinter
sudo apt-get install libatlas-base-dev