且构网

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

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

更新时间:2022-03-18 20:43:03

我在 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.

重新安装没有修复它.

这有什么帮助(找到 此处):查找 Anaconda 目录并将 Library\plugins 子目录(此处为 c:\ProgramData\Anaconda3\Library\plugins)设置为环境变量 QT_PLUGIN_PATH在控制面板/系统/高级系统设置/环境变量下.

What helped was this (found here): Look for the Anaconda directory and set the Library\plugins subdir (here c:\ProgramData\Anaconda3\Library\plugins) 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:\Users\chris\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64)已修复两个程序的问题.

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:\Users\chris\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64) fixed the problem for both programs.