win10 64位系统,安装anaconda3,python 版本3.7.4,刚开始安装了pyqt5,pyqt5-tools ,然后好用,可以使用图形界面,然后又安装了其它包或软件,就报错了,出不来图形界面。调用方式使用命令行,python test2.py,其中test2.py包含qt的图形界面程序
报错如下
qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found.
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, webgl, windows.
尝试了如下方法:
(1)pip卸载重新安装pyqt5,pyqt5-tools,
(2)将dll 文件或dll文件所在的文件夹移动到Anaconda3\Library\plugins\platforms,
(3)conda 新建虚拟环境,并安装pyqt5,pyqt5-tools,
(4)修改环境变量法,即删除QT_PLUGIN_PATH,并删除PATH里包含platforms文件夹的项,其中platforms 文件夹中包含qwindows.dll
试过以上方法,发现报错一样,论坛上说版本不对,调试了一下
SET QT_DEBUG_PLUGINS=1
python test2.py
QFactoryLoader::QFactoryLoader() checking directory path "D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms/qminimal.dll"
Found metadata in lib D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms/qminimal.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"minimal"
]
},
"archreq": 0,
"className": "QMinimalIntegrationPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms/qoffscreen.dll"
Found metadata in lib D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms/qoffscreen.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"offscreen"
]
},
"archreq": 0,
"className": "QOffscreenIntegrationPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms/qwebgl.dll"
Found metadata in lib D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms/qwebgl.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"webgl"
]
},
"archreq": 0,
"className": "QWebGLIntegrationPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("webgl")
QFactoryLoader::QFactoryLoader() looking at "D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms/qwindows.dll"
Found metadata in lib D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms/qwindows.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"windows"
]
},
"archreq": 0,
"className": "QWindowsIntegrationPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("windows")
QFactoryLoader::QFactoryLoader() checking directory path "D:/Anaconda3/platforms" ...
Cannot load library D:\Anaconda3\Lib\site-packages\PyQt5\Qt5\plugins\platforms\qwindows.dll: 找不到指定的程序。
QLibraryPrivate::loadPlugin failed on "D:/Anaconda3/Lib/site-packages/PyQt5/Qt5/plugins/platforms/qwindows.dll" : "Cannot load library D:\\Anaconda3\\Lib\\site-packages\\PyQt5\\Qt5\\plugins\\platforms\\qwindows.dll: 找不到指定的程序。"
qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found.
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, webgl, windows.
conda list 查看pyqt 的版本
pyqt 5.9.2 py37hd77b12b_6 defaults
pyqt5 5.15.9 pypi_0 pypi
pyqt5-plugins 5.15.9.2.3 pypi_0 pypi
pyqt5-qt5 5.15.2 pypi_0 pypi
pyqt5-sip 12.12.2 pypi_0 pypi
pyqt5-tools 5.15.9.3.3 pypi_0 pypi
pyqtwebengine 5.15.6 pypi_0 pypi
pyqtwebengine-qt5 5.15.2 pypi_0 pypi
我无法确认是否版本不对,也有可能是,最后又新安装了python38,然后安装pyqt5,pyqt5-tools解决的,水平有限,欢迎批评指正
参考资料:
1 Could not load the Qt platform plugin "windows" in "" even though it was found. | Qt Forum
2
"could not find or load the Qt platform plugin "windows" in "", | Qt Forum
5