问题描述
我只是尝试在 Windows 10 64 位版本上测试新发布的 PySide2 (5.11) 版本.但是Hello World"示例不起作用.我在 PyCharm 中使用 Python 3.6.我使用的解释器来自 Anaconda.所以我 pip 安装了 PySide2 版本,并尝试通过conda install ..."安装旧版本的 PySide2.两个安装都有效,但我收到两个库的相同错误消息.
I just tried to test the newly released version of PySide2 (5.11) on Windows 10, 64 bit version. But the "Hello World" example does not work. I am using Python 3.6 with PyCharm. The interpreter I use is from Anaconda. So I pip installed the PySide2 version and also tried to install via "conda install ..." the older version of PySide2. Both installations worked, but I get the same error message for both libraries.
错误消息在单独的屏幕中弹出:此应用程序无法启动,因为无法初始化 Qt 平台插件.重新安装应用程序可能会解决此问题.可用的平台插件有:minimal、offscreen、windows."
The error message is popping up in a separate screen saying: "This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: minimal, offscreen, windows."
所以我绝对可以在正确的文件夹中看到插件文件.我尝试重新安装.删除所有内容并尝试其他IDE.但没有什么能解决问题.
So I definitely can see the plugin files in the correct folder. I tried reinstalling. Deleted everything and tried other IDEs. But nothing solved the problem.
感谢任何帮助.
推荐答案
试试这个:
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
# code .......
# .......
这篇关于PySide2 应用程序启动失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!