服务器Linux版本ubuntu20.04,使用vscode远程连接服务器,在anaconda中跑工程,直接在终端中跑没问题,在tmux中跑报错:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/xx/anaconda3/lib/pythonxx/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb, eglfs, minimal, minimalegl, offscreen, vnc
咱们不需要看服务器端的图形界面,所以直接在~/.bashrc中添加export QT_QPA_PLATFORM="offscreen"
,然后source ~/.bashrc
即可。
最好重连一下,以及运行代码最好去用MobaXterm,不要直接在vscode里跑,因为它自己不带Xserver,没有配置的或者不想配置的就直接去用MobaXterm跑代码吧,亲测MobaXterm里跑问题少得多。