问题描述
第一次运行python qt时显示:
This application failed to start because no Qt platform plugin could beinitialized Reinstalling the application may fix this problem
Available platform plugins are: direct2d, minimal, offscreen, windows。
解决方法(亲测有效)
找到安装pyside2的安装包,在根目录下找到__init__.py文件
这里我的安装路径是D:\python\Anaconda3\envs\py36\Lib\site-packages\PySide2
添加如下代码即可
dirname = os.path.dirname(__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path