使用PySide2时遇到了qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it ...

使用了PySide2替换PyQT5. 所以系统里同时安装了pyqt和pyside2.

遇到了如下问题,见截图

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: direct2d, minimal, offscreen, windows.
image.png

解决办法参考了
https://stackoverflow.com/questions/41994485/error-could-not-find-or-load-the-qt-platform-plugin-windows-while-using-matplo

将如下文件

\Anaconda3\Lib\site-packages\PySide2\plugins\platforms\qminimal.dll
\Anaconda3\Lib\site-packages\PySide2\plugins\platforms\qoffscreen.dll
\Anaconda3\Lib\site-packages\PySide2\plugins\platforms\qwindows.dll

复制到这个文件夹即可
\Anaconda3\Library\plugins\platforms\

圆满解决

推荐阅读更多精彩内容