PyQt报错:Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running

发布时间 2023-12-26 15:03:42作者: 3的4次方

PyQt报错:Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running

问题描述

在远程链接ubuntu虚拟机进行开发时,报错。

解决方案

原因是pyqt需要绘制UI,而使用远程链接的终端(如windows powershell、xshell、vscode terminal等)不具有图形协议(大概),所以必须回到ubuntu虚拟机上执行代码。