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)
相关推荐
小樱花的樱花13 小时前
打造高效记事本:UI设计到功能实现
开发语言·c++·qt·ui
丁劲犇13 小时前
QMetaObject的invokeMethod异步阻塞调用在MCPServer开发中的巧妙应用
qt·ai·agent·异步·阻塞·mcp·mcp server
m0_4972141515 小时前
Qt事件系统
开发语言·qt
秋月的私语16 小时前
遥感影像拼接线优化工具:基于Qt+GDAL+OpenCV的从零到一实践
开发语言·qt·opencv
姓刘的哦17 小时前
Qt自定义控件
开发语言·qt
AlanW17 小时前
Qt Model/View 框架完全指南:从入门到性能优化
qt
Dshuishui18 小时前
VSCode 环境下编译运行 C++ 项目
c++·ide·vscode
swear0118 小时前
【VSCODE 插件 rust-analyzer 使用】打开文件夹
ide·vscode·rust
ShawnLiaoking18 小时前
Github 克隆 PyCharm,vscode
ide·pycharm·github
C1829818257518 小时前
AI idea 集成claude code插件
java·ide·intellij-idea