Rmarkdown中写入python chunk,knit时This application failed to start because it could……

问题如下:

我在Rmarkdown中写入python代码,运行都ok,但是在knit时报错如下:

Rmarkdown中写入python chunk,knit时This application failed to start because it could……

我在网上搜了很多方法,让重新安装pyqt5居多,但是我试了依然不行,最后发现是少了PyQt5的环境变量,在anaconda下有这样一个文件夹:

Rmarkdown中写入python chunk,knit时This application failed to start because it could……

需要把这个路径新添加到环境变量中,名为QT_QPA_PLATFORM_PLUGIN_PATH,如下:

Rmarkdown中写入python chunk,knit时This application failed to start because it could……

重新启动Rstudio,重新knit即可。