且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何修复“无法找到或加载 Qt 平台插件窗口"?在 PyCharm 中使用 Matplotlib 时

更新时间:2022-03-18 20:42:21

我在使用 Anaconda3 4.2.0 和 4.3.0.1(64 位)时遇到了同样的问题.当我尝试运行一个使用 matplotlib 的简单程序时,我收到了以下错误消息:

I had the same problem with Anaconda3 4.2.0 and 4.3.0.1 (64-bit). When I tried to run a simple program that uses matplotlib, I got this error message:

This application failed to start because it could not find or load the Qt platform plugin "windows"

Reinstalling the application may fix this problem.

重新安装并没有解决它.

Reinstalling didn't fix it.

这有什么帮助(发现 这里):查找 Anaconda 目录并将 Libraryplugins 子目录(此处为 c:ProgramDataAnaconda3Libraryplugins)设置为环境变量 QT_PLUGIN_PATH在控制面板/系统/高级系统设置/环境变量下.

What helped was this (found here): Look for the Anaconda directory and set the Libraryplugins subdir (here c:ProgramDataAnaconda3Libraryplugins) as environment variable QT_PLUGIN_PATH under Control Panel / System / Advanced System Settings / Environment Variables.

设置变量后,如果更改没有立即生效,您可能需要重新启动 PyCharm.

After setting the variable you might need to restart PyCharm, if the change does not have an immediate effect.

即使在那之后命令行 Python 工作了,TexWorks(它也使用 Qt)显示了一个非常相似的错误消息.将 QT_PLUGIN_PATH 设置为包含 TexWorks 的 Qt DLL 的目录(此处为 C:UserschrisAppDataLocalProgramsMiKTeX 2.9miktexinx64)已修复两个程序的问题.

Even though after that the command line Python worked, TexWorks (which uses Qt as well) displayed an error message very much like it. Setting the QT_PLUGIN_PATH to the directory containing TexWorks' Qt DLLs (here C:UserschrisAppDataLocalProgramsMiKTeX 2.9miktexinx64) fixed the problem for both programs.