How to fix “could not find or load the Qt platform plugin windows” while using Matplotlib in PyCharm

前端 未结 21 877
迷失自我
迷失自我 2020-12-02 13:00

I am getting the error \"could not find or load the Qt platform plugin windows\" while using matplotlib in PyCharm.

How can I solve this?

相关标签:
21条回答
  • 2020-12-02 13:33

    I found that this was being caused by having the MiKTeX binaries in my PATH variable; and the wrong Qt dll's were being found. I just needed to re-arrange the PATH entries.

    (Dependency Walker is such a useful tool.)

    0 讨论(0)
  • 2020-12-02 13:34

    If you want to visualize your matplotlibs in an alternative way, use a different backend that generates the graphs, charts etc.

    import matplotlib
    matplotlib.use('TKAgg')
    

    This worked for me.

    0 讨论(0)
  • 2020-12-02 13:36

    Copy the folder

    \Anaconda3\Library\plugins\platforms
    

    to

    \$\
    

    where $ is your project interpreter folder. For example:

    "\project\anaconda_env\Scripts\"
    

    because PyCharm calls the python.exe in this folder, not the one in \Anaconda3.

    0 讨论(0)
  • 2020-12-02 13:36

    I had the same issue with Qt 5.9 example btscanner.exe. What works in my case is:

    1. Create a folder where is btscanner.exe ( my is c:\temp\BlueTouth )
    2. Run from command prompt windeployqt.exe as follow: c:\qt\qt5.9.0\msvc2015\bin\windeployqt c:\temp\BlueTouth /* windeplyqt is the standard Qt tool to packet your application with any needed libraries or extra files and ready to deploy on other machine */

    3. Result should be something like that:

    C:\temp\BlueTouth\btscanner.exe 32 bit, release executable
    Adding Qt5Svg for qsvgicon.dll
    Skipping plugin qtvirtualkeyboardplugin.dll due to disabled dependencies.
    Direct dependencies: Qt5Bluetooth Qt5Core Qt5Gui Qt5Widgets
    All dependencies   : Qt5Bluetooth Qt5Core Qt5Gui Qt5Widgets
    To be deployed     : Qt5Bluetooth Qt5Core Qt5Gui Qt5Svg Qt5Widgets
    Warning: Cannot find Visual Studio installation directory, VCINSTALLDIR is not set.
    Updating Qt5Bluetooth.dll.
    Updating Qt5Core.dll.
    Updating Qt5Gui.dll.
    Updating Qt5Svg.dll.
    Updating Qt5Widgets.dll.
    Updating libGLESV2.dll.
    Updating libEGL.dll.
    Updating D3Dcompiler_47.dll.
    Updating opengl32sw.dll.
    Patching Qt5Core.dll...
    Creating directory C:/temp/BlueTouth/iconengines.
    Updating qsvgicon.dll.
    Creating directory C:/temp/BlueTouth/imageformats.
    Updating qgif.dll.
    Updating qicns.dll.
    Updating qico.dll.
    Updating qjpeg.dll.
    Updating qsvg.dll.
    Updating qtga.dll.
    Updating qtiff.dll.
    Updating qwbmp.dll.
    Updating qwebp.dll.
    Creating directory C:/temp/BlueTouth/platforms.
    Updating qwindows.dll.
    Creating C:\temp\BlueTouth\translations...
    Creating qt_bg.qm...
    Creating qt_ca.qm...
    Creating qt_cs.qm...
    Creating qt_da.qm...
    Creating qt_de.qm...
    Creating qt_en.qm...
    Creating qt_es.qm...
    Creating qt_fi.qm...
    Creating qt_fr.qm...
    Creating qt_gd.qm...
    Creating qt_he.qm...
    Creating qt_hu.qm...
    Creating qt_it.qm...
    Creating qt_ja.qm...
    Creating qt_ko.qm...
    Creating qt_lv.qm...
    Creating qt_pl.qm...
    Creating qt_ru.qm...
    Creating qt_sk.qm...
    Creating qt_uk.qm...
    
    1. If you take e look at c:\temp\BlueTouth folder will see the folders iconengines, imageformats, platforms, translations, and files D3Dcompiler_47.dll, libEGL.dll, libGLESV2.dll, opengl32sw.dll, Qt5Bluetouth.dll, Qt5Core.dll, Qt5Gui.dll, Qt5Svg.dll, Qt5Widgets.dll.

    These are all of the files and folders need to run btscanner.exe on this or another machine. Just copy whole folder on other machine and run the file.

    0 讨论(0)
  • 2020-12-02 13:39

    If you are running PyQt5 and PySide2, this solved the problem for me:

    Copy the following files:

    \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
    

    to:

    \Anaconda3\Library\plugins\platforms\
    
    0 讨论(0)
  • 2020-12-02 13:39

    Just add a system variable:

    QT_QPA_PLATFORM_PLUGIN_PATH
    

    and set its value to

    C:\Python34\Lib\site-packages\PyQt4\plugins\platforms
    

    Voilà. Done

    0 讨论(0)
提交回复
热议问题