matplotlib画图报错
在python中使用matplotlib画图时,经常报如下错误:
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
由报错信息可知,无法找到“xcb”插件,在代码中添加如下代码,设置环境变量,方便调试:
os.environ['QT_DEBUG_PLUGINS'] = '1'
这时候运行画图程序,报如下错:
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/nas/pangshumao/software/anaconda3/bin/platforms" ...
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
即在路径"/mnt/nas/pangshumao/software/anaconda3/bin/platforms"下无法找到“xcb”插件,在命令行设置如下环境变量即可解决问题:
export QT_PLUGIN_PATH=/mnt/nas/pangshumao/software/anaconda3/plugins