PyQt5 - Failed to load platform plugin “windows”. Available platforms are: windows, minimal

前端 未结 8 1025
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 02:27

When I try to run any PyQt5 program from Eclipse, I got this error.

Failed to load platform plugin \"windows\". Available platforms are: windows, mini

相关标签:
8条回答
  • 2020-12-06 02:51

    I like uetoyo's answer, but Anaconda has moved the directory. This works for me Python 3.5.2 Anaconda 4.2.0 on Windows 7.

    import os
    if os.name == "nt":  # if windows
        import PyQt5
        pyqt_plugins = os.path.join(os.path.dirname(PyQt5.__file__),
                                    "..", "..", "..", "Library", "plugins")
        QApplication.addLibraryPath(pyqt_plugins)
    
    0 讨论(0)
  • 2020-12-06 02:57

    if you use PySide2 you can check with this

    import os
    if os.name == 'nt':
        import PySide2
        pyqt = os.path.dirname(PySide2.__file__)
        QApplication.addLibraryPath(os.path.join(pyqt, "plugins"))
    
    0 讨论(0)
  • 2020-12-06 02:59

    I encountered this issue with PyQt5 5.0.2, Windows 8, Python 3.3.2; slightly different error message:

    Failed to load platform plugin "windows". Available platforms are:

    Set the following environment variable and then run the application.

    $env:QT_QPA_PLATFORM_PLUGIN_PATH="C:\Python33\Lib\site-packages\PyQt5\plugins\platforms"

    0 讨论(0)
  • 2020-12-06 03:03

    i had a similar problem when compiling my code with cx_freeze.

    Copying the folder platforms from python installation directory into my built folder solved the problem. the "platforms" folder contains qminimal.dll

    0 讨论(0)
  • 2020-12-06 03:04

    I found the file: qwindows.dll needed to be included to allow my .exe file to run independently without getting the error. To do so, add the qwindows.dll path to your data files list:

    setup(windows=[YOURSCRIPT.py]
    , data_files = [('.','DRIVE:\PythonPath\Lib\site-packages\PyQt4\plugings\platforms\qwindows.dll')]) 
    

    The reason you would do this and now set your environment path is that your program will run on any machine if the qwindows.dll file is held in the same package. If you only set the environment variable, the program will only successfully run on a computer with PyQt installed.

    0 讨论(0)
  • 2020-12-06 03:08

    Another solution which works for me; Windows 7; PyQt5, Python 3.4 64bit:

    pyqt = os.path.dirname(PyQt5.__file__)
    QApplication.addLibraryPath(os.path.join(pyqt, "plugins"))
    

    You can also set an environment variable QT_QPA_PLATFORM_PLUGIN_PATH with the path to the plugins directory.

    os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = qt_platform_plugins_path
    

    This also works very well with PyInstaller!

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