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

前端 未结 8 1091
伪装坚强ぢ
伪装坚强ぢ 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 03:12

    This is what worked for me while using the Anaconda Python 3.6 distribution:

    1. I installed PyQt5 using pip install pyqt5. What this does is it creates a Qt/Pluginsplugins directory in the ../Anaconda3/Lib/site-packages/PyQt5 path.

    2. Following Roger Allen and uetoyo, I added:

    if os.name == "nt":  # if windows
        from PyQt5 import __file__
        pyqt_plugins = os.path.join(os.path.dirname(__file__), "Qt", "plugins")
        QApplication.addLibraryPath(pyqt_plugins)
        os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = pyqt_plugins
    

    to my script. It works with pyinstaller as well.

提交回复
热议问题