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

前端 未结 21 878
迷失自我
迷失自我 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:39

    First, use the command:

    conda remove pyqt qt qtpy

    Then install using:

    conda install pyqt qt qtpy

    This worked for me.

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

    I had a similar problem with PyCharm where things worked great in main run but not in debugger, getting the same error message. This happened for me because I had moved my Anaconda installation to a different directory. The debugger goes and checks a qt.conf file that is located at the same place as python. This location can be found by running import sys; print sys.executable. I found this solution through a pile of web searches and it was buried deep here. The qt.conf file needs to have correct paths for debugger to work.

    My qt.conf files looks like this in notepad:

    [Paths]
    Prefix = E:/python/Anaconda3_py35/Library
    Binaries = E:/python/Anaconda3_py35/Library/bin
    Libraries = E:/python/Anaconda3_py35/Library/lib
    Headers = E:/python/Anaconda3_py35/Library/include/qt
    
    0 讨论(0)
  • 2020-12-02 13:41

    I had the same issue. Following "Activating an environment" in "Managing environments" solved the issue.

    In the command line:

    conda activate myenv
    

    where myenv=base for my setup.

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

    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.

    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.

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


    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.

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

    In my case, I had multiple combined problems in order to make PyQt5 run on Windows, see DLL load failed when importing PyQt5

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

    I have the same issue and fixed in this way In Anaconda installation folder I went to : (change it to your installed path): C:\ProgramData\Anaconda3\Lib\site-packages\PySide2 Edit this file by adding the following code lines :

    # below the line 23 type.__signature__
        pyside_package_dir =  os.path.abspath(os.path.dirname(__file__))
        dirname = os.path.dirname(__file__)
        plugin_path = os.path.join(dirname, 'plugins', 'platforms')
        os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
    

    save this file and try again and the issue should be gone :)

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