当前位置: 代码迷 >> 综合 >> Ubuntu pyinstaller 打包可执行文件时报错:... qt.qpa.plugin: Could not find the Qt platform plugin “xcb“ in “...
  详细解决方案

Ubuntu pyinstaller 打包可执行文件时报错:... qt.qpa.plugin: Could not find the Qt platform plugin “xcb“ in “...

热度:32   发布时间:2023-12-25 20:18:16.0

Ubuntu pyinstaller 打包可执行文件时报错:qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

  • 问题
  • 解决办法


问题

Ubuntu pyinstaller 打包可执行文件时,报错:
QFactoryLoader::QFactoryLoader() checking directory path “/home/dyj/CarUI/dist/carmain/platforms” … qt.qpa.plugin: Could not find the Qt platform plugin “xcb” in “” This application failed to start because no Qt platform plugin could be initialized.
在这里插入图片描述

解决办法

在自己的主程序代码中加入以下代码:

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

在这里插入图片描述
参考链接:https://blog.csdn.net/ouening/article/details/81093697#commentBox

  相关解决方案