使用python qt时显示This application failed to start because no Qt platform plugin...错误

问题描述

第一次运行python qt时显示:
This application failed to start because no Qt platform plugin could beinitialized Reinstalling the application may fix this problem
Available platform plugins are: direct2d, minimal, offscreen, windows。
在这里插入图片描述

解决方法(亲测有效)

找到安装pyside2的安装包,在根目录下找到__init__.py文件
这里我的安装路径是D:\python\Anaconda3\envs\py36\Lib\site-packages\PySide2
在这里插入图片描述
添加如下代码即可

dirname = os.path.dirname(__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

在这里插入图片描述

  • 6
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
出"This application failed to start because no Qt platform plugin could be initialized"错误是因为在pycharm运行程序缺少Qt平台插件的库文件。这个错误通常发生在缺少xcb库文件或者没有正确配置Qt平台插件路径的情况下。 解决这个问题的方法是确保正确安装了Qt平台插件,并将插件路径配置到环境变量中。 首先,你可以尝试重新安装应用程序,这可能会修复问题。如果问题仍然存在,可以按照以下步骤解决问题: 1. 找到你的Qt平台插件的路径,通常是在你的pycharm安装目录下的qt/plugins文件夹中。 2. 打开pycharm,点击"File",然后选择"Settings"。 3. 在"Settings"窗口中,选择"Build, Execution, Deployment",然后选择"Python Interpreter"。 4. 在"Python Interpreter"页签中,选择你的项目的解释器。 5. 在右侧的"Environment"字段中,点击编辑按钮。 6. 在编辑环境变量的对话框中,添加一个新的环境变量,名称为"QT_QPA_PLATFORM_PLUGIN_PATH",值为Qt平台插件的路径。 7. 点击确定保存更改。 现在,重新运行程序,应该就能够正常启动了。如果问题仍然存在,可能是由于其他问题引起的,你可以尝试重新安装Qt和pycharm,或者在开发环境中查找其他解决方案。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [This application failed to start because no Qt platform plugin could be initialized. Reinstalling th](https://blog.csdn.net/weixin_45297905/article/details/127703251)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [成功解决This application failed to start because no Qt platform plugin could be initialized.](https://blog.csdn.net/weixin_62087061/article/details/128910228)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YSC7

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值