祝各位道友念头通达
GitHub Gitee 语雀 打赏

pyside6 qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""

报错

pyside6 qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""

解决方案

在设置系统环境变量之后, 开发的时候没问题,打包运行到别人的电脑上的时候就会出同样的问题, 采用第二个方案可以解决

1. 将环境变量设置到 QT_QPA_PLATFORM_PLUGIN_PATH

1.1 如果不知道pyside6 在那个文件夹,可以通过以下方式获取

import os, PySide6
print(os.path.dirname(PySide6.__file__))

1.2 然后将打开系统环境变量

输入 QT_QPA_PLATFORM_PLUGIN_PATH, 路径为上述代码打印, 然后上述错误即可解决
image

2. 设置系统代码, 打包之后运行到别的电脑也可运行

import os, PySide6

dirname = os.path.dirname(PySide6.__file__)
print(dirname)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
print(plugin_path)
posted @ 2022-11-16 17:24  韩若明瞳  阅读(823)  评论(0编辑  收藏  举报