描述错误
启动 pyside2 程序,报错如下:
This application failed to start because not Qt platform plugin could be initialized.Reinstalling the application may fix this problem.
解决方式一
在程序初始部分添加如下代码:
dirname = os.path.dirname(PySide2.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
注意
使用这种方式,可能失去windows10样式,是windows早期的版本,可增加下面代码,启用 Fusion 样式,各个平台一致的UI界面:
QApplication.setStyle("Fusion")
其他方式
https://blog.csdn.net/weixin_43917589/article/details/106137952
