[Python] How to resolve "no Qt Platform Plugin could be initialized" for a Qt5 application?

Discussão em 'Python' iniciado por Stack, Janeiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    I am working on a python application based on PyQt5. Everything was running good until I redo my PC and reinstall windows again because of some issue. I had copied my environment and after reinstalling Anaconda, I copied that environment again in env folder. Now the problem is that, when I run my code in PyCharm IDE, it displays and error dialog like this:

    [​IMG]

    I have tried multiple solutions such as:

    Solution 1: Change the QT Files Location

    Sometimes, a simple trick such as changing the QT files location is enough to get rid of the error. Here’s how you can do it:

    1. Launch File Explorer and open This PC.
    2. Using the Search field, search for pyqt5_tools.
    3. When Windows finishes the search, right-click the pyqt5_tools and head to Open folder location.
    4. Head to PyQt5 > Qt > bin. Copy the platforms folder. in my case bin is not available in this folder
    5. Make a new search for site-packages and open the folder.
    6. There, paste the platforms folder.
    7. Windows will warn you there’s already a folder with the same name. Click Replace the files in the destination.

    Solution 2: Run an SFC Scan

    There’s a chance Windows display the “Application failed because no QT platform plugin could be initialized” error due to corrupt system files. Fortunately, Windows has a built-in tool to help you fix the problem.

    In the Start menu search bar, search for command prompt and select Run as administrator. Then, run the sfc /scannow command line. Windows will scan and automatically replace any corrupted system file.

    Solutions Reference

    Nothing worked for me, I'm getting the same error all the time. How can I resolve the error displayed in the figure above?

    Any help will be appreciated, Thanks.

    Continue reading...

Compartilhe esta Página