PySide2的This application failed to start because no Qt platform plugin could be initialized解决方式
解决PySide2的This application failed to start because no Qt platform plugin could be initialized问题
今天在装pyside2的时候心路历程可谓是十分艰辛了,好在最后都解决了。
首先是pip install时一直retrying的问题,与之同时发生的还有win10的手动设置代理一直打开,经过一系列搜索解决方法无果,最后我想起来之前使用ssr时因为代理没有效果删除了,删除前的一系列设置可能对这个有一定的影响,然后就又下载了回来,搞定了代理后pip就完全ok了。
之后就是标题所写的pyside2进行gui窗口编程时发生的错误了,同样经过了一系列的搜索折磨,最后在不停地吐槽国内博客转来转去找不到几个原创的答案之中,最后搜了下stackoverflow,然后就解决了。
总结一下思路:国内博客中通常是修改环境变量,这点是完全没问题的,但是由于国内博客大多写的是pyqt而不是pyside2,所以配置环境变量有所区别。
其实解决问题的方法也是配置环境变量,只不过路径不能只写到plugin,而要把platform也加入进去,当然也可以在每次编程时先加入这段代码再继续自己的代码:
import sys,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
如果想要一劳永逸,那么就多打一条print看一下pyside2安装目录:
import sys,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
print(plugin_path)
把输出获得的路径复制一下(第二行):

然后在环境变量中配置一下就可以了:

但配置环境还是有可能不行,那么有一个办法是基本可行的,也就是改包根目录下的__init__文件,在注释前加上上面的那串代码就可以(注意要把PySide2去掉):

PySide2的This application failed to start because no Qt platform plugin could be initialized解决方式的更多相关文章
- 【环境搭建】安装pyQt5 在pycharm报This application failed to start because no Qt platform plugin could be initialized的问题
报错:This application failed to start because no Qt platform plugin could be initialized 解决办法: http:// ...
- 解决QT5移植报错:This application failed to start because no Qt platform plugin could be initialized
今天自己基于Pyqt5开发了一个软件,打包成exe后在自己的电脑上运行正常,在其他机器上提示: This application failed to start because no Qt platf ...
- This application failed to start because no Qt platform plugin could be initialized
今天在直接运行QT生成的.exe遇到了一个错误:This application failed to start because no Qt platform plugin could be init ...
- is application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem
最近试着了解 c++,接触到了QT,写了一个测试程序,在开发环境下正常后移到非开发环境,报错 网上找资料说是少了platforms文件夹中的dll,把里面所有的dll复制到执行程序目录,还是提示,继续 ...
- pthon-安装新版PyQt5、PyQT5-tool后打不开并Designer.exe提示“This application failed to start because no Qt platform plugin could be initialized.Reinstalling the application the application may fix this program”
最近学习python,安装网上教程一步一步的安装,网上很多帖子都写的非常详细,不由深深感慨多谢各位不辞辛苦的记录,指导着来自新入门的同学. 但是实际安装中,最理想莫过于一次性安装成功,但自己安装就出现 ...
- This application failed to start because it could not find or load the Qt platform plugin "xcb".
1. copy libQt5DBus.so.5 2. add QT_PLUGIN_PATH blog.csdn.net/windows_nt/article/details/242 ...
- This application failed to start because it could not find or load the Qt platform plugin "xcb".
linux根据系统Qt5未安装编译的程序Qt在该系统下进行下面的错误会报: This application failed to start because it could not find or ...
- The trust relationship between this workstation and the primary domain failed(断网可以登进来)(正确的解决方式用管理员登进去 :退域再加域)
The trust relationship between this workstation and the primary domain failed(断网可以登进来)(正确的解决方式用管理员登进 ...
- This application failed to start because it could not find or load the Qt platform plugin “windows”错误解决方法
这是一个困扰我很久的问题,关于Qt下生成的exe文件在没有安装Qt的机器上无法运行的问题.Qt是编写C++图形界面的一个很好工具,比MFC来的直观.可是,Qt的安装却是一个让人头疼的事情.早在上个学期 ...
随机推荐
- 创想变现:斯坦福设计创新课堂ME310分享(上篇)
编者按:今年6月,微软亚洲研究院人机交互组研究员顾嘉唯,在美国斯坦福大学担任了d-School的ME310设计课程的项目评审.该课程是斯坦福大学的全球联合新产品设计创新课程,学习方式以小组为单位,每个 ...
- 在SpringBoot中使用Junit测试
一:加入依赖 <dependency> <groupId>junit</groupId> <artifactId>junit</artifactI ...
- [LC] 222. Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree ...
- SQL语句:把Excel文件中数据导入SQL数据库中的方法
1.从Excel文件中,导入数据到SQL数据库情况一.如果接受数据导入的表不存在 select * into jd$ from OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ...
- python后端面试第一部分:python基础--长期维护
1. 为什么学习Python? 2. 通过什么途径学习的Python? 3. Python和Java.PHP.C.C#.C++等其他语言的对比? 4. 简述解释型和编译型编程语言? https:/ ...
- Jump Game (Medium)
主要有两种思路: 一. 本题只需要判断能否到达最后一个数,那么可以采用贪心策略,到达某个位置i后,在直接在这个位置的基础上走nums[i]步,主要保证能一直前进,就能达到终点: 那么,什么时候才不能一 ...
- Python: Socket网络编程,多线程处理小Demo
一个简单的例子,深入研究一下socket的多线程处理任务 Server端: #!/usr/bin/env python #encoding:utf8 # # 注意:定义encoding时必须在第二行 ...
- python开发时小问题之端口占用
昨天开发时遇到个小问题: 在使用pycharm编写tornado代码时: 直接用这种方式开启了服务,当我想修改代码时发现端口已经被占用代码提交不上去 所以现在该关闭进程: 步骤一: 打开CMD 步骤二 ...
- Linux(Centos7.X ) 配置Java 环境变量
前提条件:上传Jdk 文件到Linux服务器上. tar -zxvf jdk-8u111-linux-x64.tar.gz 修改 /etc/profile 在打开的文件末尾添加如下内容: export ...
- Java IO: 异常处理
原文链接 作者:Jakob Jenkov 译者: 李璟(jlee381344197@gmail.com) 流与Reader和Writer在结束使用的时候,需要正确地关闭它们.通过调用close()方法 ...