Pyside2提示 Could not load the Qt platform plugin "windows" in "" even though it was found. 问题

帅比萌擦擦* 提交于 2020-01-31 05:22:57

使用pyside2时出现如下问题,主要是缺少环境变量所致,可以直接在系统中添加或是通过代码解决。

qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: direct2d, minimal, offscreen, windows.

在代码头部添加如下:

import os
import PySide2
dirname = os.path.dirname(PySide2.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!