PYCHARM PYSIDE6 QT 打包异常3种处理方式 no qt platform plugin could be initialized

安装有PYSIDE6的电脑

异常错误 ... no qt platform plugin could be initialized ...

变量名:QT_QPA_PLATFORM_PLUGIN_PATH (一个字都不能改!!)

自己环境变量值:D:\Users\topma\anaconda3\Lib\site-packages\PySide6\plugins\platforms

(因下载时的路径差异而有所不同,重点是找到你电脑里【PySide2】文件夹下的【plugins】→【platforms】 )

设置好后,点击【确定】→【确定】,重启电脑!!!!!!

重启电脑后,重复上述打包成exe的步骤,再次双击生成的exe文件(或许)可解决报错问题。

原文链接:https://blog.csdn.net/Melody_Uo/article/details/119930331

没有安装PYSIDE 的电脑

将 PYSIDE6 的platforms文件拷贝到打包程序文件夹。

终极解决方式

QT DLL 打包进程序,运行时新建个目录拷贝出来。

c 复制代码
if getattr(sys, 'frozen', False):
    print("frozen OK")
    folder = Path(__file__).parent#folder = Path(sys._MEIPASS)
    source_path = folder / 'platforms'
    target_path=os.getcwd() + "\\"+"platforms"
    print(target_path)
    if not os.path.exists(target_path):
        # 目录不存在,进行创建操作
        os.makedirs(target_path)  # 使用os.makedirs()方法创建多层目录
        print("目录新建成功:" + target_path)
    else:
        print("目录已存在!!!")
    if os.path.exists(source_path):
        for root, dirs, files in os.walk(source_path):
            for file in files:
                src_file = os.path.join(root, file)
                shutil.copy(src_file, target_path)
                print(src_file)
相关推荐
纪伊路上盛名在6 小时前
windows 配置vscode x11转发
ide·vscode·编辑器
comedate9 小时前
Cursor 和 GitHub Copilot 怎么选?2026 年 AI 编程助手对比
ide·ai编程·cursor·github copilot
布莱克60510 小时前
QtWidgets 与 QML:两大 UI 开发框架的全面对比
开发语言·c++·qt·ui·架构
2501_9151063212 小时前
KXApp 的 VS Code 真机调试:按下 Cmd+R 之后发生了什么
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
qq_4017004112 小时前
Qt 实时大数据量存储:自己动手实现 TDMS 读写
数据库·qt
NiceBlueChai12 小时前
Qt 跨线程传递多容器嵌套结构:一次 Release 实测
开发语言·qt
扶尔魔ocy12 小时前
【QT android】模仿行车记录仪案例
android·qt
hkj880812 小时前
VsCode的使用
ide·vscode·编辑器
zhanghaha13141 天前
Qt 类本质就是 C++ 的类,只是 Qt 框架扩展了一套【QObject 对象模型】
qt
不像程序员的程序媛1 天前
maven基础
python·pycharm·maven