Qt qpa plugin could not find the qt platform plugin windows in

I read a lot of questions and answers related to this issue. However, none of them solved my problem.

I would like to point out that i am using the 5.12.2 of Qt. In addition, i tried to generate .exe files using windeployqt command (Calling it via the cmd).

So, i have two different qt application (2 .exe files). I transfer them in a different windows machine with no Qt installation. One .exe file is running correctly however the other one gives me back the error related to the qt platform plugin «Windows».

I would like also to point out, that the running exe is produced using Qt 5.12.2 (MinGW 7.3.0 64-bit). For the problematic exe, the 5.12.2 (MinGW 7.3.0 32-bit) is used.

Do you know what will be the problem?

PS. i double check that the qwindows.dll is in the platforms folder. I also tried to put this dll in the same folder as the exe file as well as in a sub-folder called plugins (based on some answers find around the web.)

Thanks a lot,

asked Jun 12, 2019 at 10:56

Elena Valari's user avatar

0

I encountered this issue with PyQt5 5.11.3, Windows 10, Python 3.7.3; I got a similar error message:

qt.qpa.plugin: Could not find the Qt platform plugin «windows» in »
This application failed to start because no Qt platform plugin could
be initialized. Reinstalling the application may fix this problem.

I set the following environment variable and then run the application. This Method had solved my question, I hope it is helpful for you:

name:  QT_QPA_PLATFORM_PLUGIN_PATH
value: C:\Users\"your own user 
name"\AppData\Local\Programs\Python\Python37\Lib\site- 
packages\PyQt5\Qt\plugins\platforms

Hasitha Jayawardana's user avatar

answered Jul 11, 2019 at 2:26

XinHu's user avatar

XinHuXinHu

313 bronze badges

2

Are these exe files in the same folder ? If so you need to put the in 2 different folders as they will not use the same DLLs (including qwindows.dll). One exe needs 32-bit DLLs and the other one 64-bit DLLs.

If they are already in 2 seperate folders, make sure you have run the correct windeployqt on each of them.

You need to use the windployqt.exe from your «Qt 5.12.2 (MinGW 7.3.0 64-bit)» installation on the 64-bit exe. And use the windployqt.exe from your «Qt 5.12.2 (MinGW 7.3.0 32-bit)» installation on the 32-bit exe.

Also be sure to copy the Qt5Core.dll using windeployqt and not by doing a manual copy/paste. The reason is that windeployqt patches Qt5Core.dll when copying it so that it searches plugins relatively to your exe.

answered Jun 12, 2019 at 11:36

Benjamin T's user avatar

Benjamin TBenjamin T

8,14020 silver badges38 bronze badges

Scripteer

Андрей Андреев

@Scripteer

Веб дизайнер, интересуюсь python, знаю html,css +-

У меня появилась ошибка когда запускаю python файл, пж помогите не нужно кидать ссылку на форум просто скажите что сделать?

ОШИБКА

C:\Users\Андрей>»C:\Users\Андрей\Desktop\Currency Convertor\ui.py»
qt.qpa.plugin: Could not find the Qt platform plugin «windows» in «»
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.


  • Вопрос задан

  • 14947 просмотров

РЕШЕНИЕ: Найти папку где установлен python, перейти по пути C:\Users\Андрей\AppData\Local\Programs\Python\Python38\Lib\site-packages\PyQt5\Qt\plugins найти тут папку platforms и перенести в папку где находится python

Пригласить эксперта


  • Показать ещё
    Загружается…

08 окт. 2023, в 23:50

5000 руб./за проект

08 окт. 2023, в 21:59

1000 руб./в час

08 окт. 2023, в 20:00

10000 руб./за проект

Минуточку внимания

I am implementing qgis 3.4.3 in a custom application, but when I instantiate the QgsApplication() class, I receive the error «Could not find the Qt platform plugin «Windows» in «».

I’ve attempted using various installs of qgis 3.x+ including the standalone installer and OSGeo4W web installer. I currently am sticking with the OSGeo4W web installer installation. I am using a Python 3.7 installation separate from what comes with OSGeo4W and attempting to integrate qgis functionality.

I have followed the instructions in the following QGIS help doc under the section: «Using PyQGIS in Custom Applications»
https://docs.qgis.org/2.18/en/docs/pyqgis_developer_cookbook/intro.html#run-python-code-when-qgis-starts

After attempting to run the script I realized a dll plugin was missing. After some research, I found its the qwindows.dll that qt uses. The qwindows.dll is included in the OSGeo4W installation under: C:\OSGeo4W\apps\Qt5\plugins\platforms

I changed the QT_PLUGIN_PATH variable on the local command prompt to include the directory above, but the same error prevailed. I also changed the QT_DEBUG_PLUGINS variable to 1 which printed out the locations Qt is looking for plugins. Interestingly, it wasn’t looking for plugins in the path I specified in the QT_PLUGIN_PATH variable.

Python Code:

import sys
#add qgis python libraries to instance python path in case not added 
#at the environment variable %PYTHONPATH% level
sys.path.extend(['C:\\OSGeo4W\\apps\\qgis\\python', 
'C:\\OSGeo4W\\apps\\Python37\\Lib\\site-packages'])

from qgis.core import *

# supply path to qgis install location
QgsApplication.setPrefixPath('C:\\OSGeo4W\\apps\\qgis', True)

# create a reference to the QgsApplication
# setting the second argument to True enables the GUI, which we need to do
# since this is a custom application
qgs = QgsApplication([], True)

# load providers
qgs.initQgis()

# Write your code here to load some layers, use processing algorithms, etc.

# When your script is complete, call exitQgis() to remove the provider and
# layer registries from memory
qgs.exitQgis()

Batch File Code to Start Cmd Prompt with Proper Variables:

@echo off
SET OSGEO4W_ROOT=C:\OSGeo4W
::Include environment variables set by qgis on startup
call %OSGEO4W_ROOT%\bin\o4w_env.bat
call %OSGEO4W_ROOT%\bin\qt5_env.bat
call %OSGEO4W_ROOT%\bin\py3_env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;C:\OSGeo4W\apps\Qt5\bin
path %PATH%;C:\OSGeo4W\apps\Python37\Scripts
path %PATH%;C:\OSGeo4W\apps\Python37

set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\Qt5\plugins;%OSGEO4W_ROOT%\apps\qgis\qtplugins
set QT_DEBUG_PLUGINS=1

cmd.exe

I expect to run the python script and receive no errors since I’m pointing to the directory where the qwindows.dll missing plugin is stored. However, I am still receiving the missing windows plugin error.

Here is the actual message with QT_DEBUG_PLUGINS set to 1:
QFactoryLoader::QFactoryLoader() checking directory path «C:/OSGeo4W/apps/qgis/qtplugins/platforms» …
QFactoryLoader::QFactoryLoader() checking directory path «C:/OSGeo4W/apps/Python37/platforms» …
qt.qpa.plugin: Could not find the Qt platform plugin «windows» in «»
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Description of the issue

When packaging an app which uses PySide6 (which seems to be a recent release, December 2020), the app builds fine but upon execution it crashes with the error qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "".

This can be fixed by copying over the platforms folder from [env]\Lib\site-packages\PySide6\plugins into the pyinstaller dist directory (or where the executable is, if built with --onefile)

From googling around, it seems like people had this same problem back in the PyQt5 days, and seemed to have been fixed with
this pull request. The reason this might still broken might be that all the checks in pyinstaller/PyInstaller/utils/hooks/qt.py use an hardcoded «PySide2» string, while the newer package has been renamed to PySide6.

That’s made more likely from the fact that using PySide2 works (noting that all documentation / homepage links for it redirect to PySide6, pretty confusing naming scheme)

Context information (for bug reports)

  • Output of pyinstaller --version: 3.6
  • Version of Python: 3.9.1
  • Platform: Windows-10-10.0.19041-SP0
  • Did you also try this on another platform? Does it work there? Haven’t tried, but likely not

A minimal example program which shows the error

import sys

import PySide6.QtGui
import PySide6.QtCore
from PySide6.QtWidgets import QApplication, QMainWindow

class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.show()

def main():
    a = QApplication(sys.argv)
    w = MainWindow()
    sys.exit(a.exec_())

if __name__ == "__main__":
    main()

Stacktrace / full error message

qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

@HZMD said in «could not find or load the Qt platform plugin «windows» in «»,:

Do all of them use Qt? — I’m not sure, and I’m not sure how to find out.

In general, you check for the presence of Qt DLLs (Qt5Core.dll, qwindows.dll) in the program’s folders.

How did I install Krita? — It would be non-helpful if I said «in the normal way» wouldn’t it? I’m definitely not a proper programmer, though I’m «programmer adjacent» in some aspects of my work, learning enough from programmers to describe it to non-programmers in pictures. Anyway, I downloaded an executable installer from Krita.org and let it do its thing. Is that the right information?

Yes, that’s the right information :) Other possible ways to install Krita include «compile it from source».

Anyway, since you used the «normal way», that rules out the possibility of the error being caused by incorrect installation/compilation/deployment

Does uninstalling and reinstalling help? — On the others I have encountered this problem with, it has. I haven’t done Krita yet, because I was hoping to find the original culprit, and thought there might be clues.

From the symptoms you’ve described and the ListDLLs output you posted, I can’t see an easy way to find the root culprit, unfortunately.

The easiest thing to do might be to reinstall the affected software and move on with your life.

One other thing you could try: If you create a new user account on your PC, does that account manage to run the affected programs normally? If it does, that means something has gone wrong in your current Windows account itself. (I can’t explain how though)

qwindows.dll is missing — Hey, I think Krita uses Qt! I found qwindows.dll in C:\Program Piles\Krita (x64)\bin\platforms

Using that newfound knowledge, I looked for it in…

…I’ll come back and edit this with any others it finds, or that it finds in Program Files (x86)

That’s OK, you don’t have to give us a comprehensive list.

I asked about other Qt-based software because sometimes, problems occur when a piece of Qt-based software adds itself to the system-wide PATH (or QT_PLUGIN_PATH). This can cause other Qt-based software to load the wrong version of Qt DLLs.

However, given that you can repair individual programs by re-installing them, that probably means your problem is caused by something else.

I did not find qwindows in the folder of the pen display driver / control software I suspected of having monkeyed things up. Am I right in thinking that means that driver / control software is innocent? With no more evidence than I had before, I now suspect Logitech. I’m sure this is how witch trials get started. ;)

It is difficult to prove that someone/thing didn’t do it.

  • Qualcomm atheros ar5007eg wireless network adapter драйвер windows 10
  • Qt online installer for windows download
  • Qualcomm atheros ar928x wireless network adapter windows 10
  • Qt postgresql driver not loaded windows
  • Qualcomm atheros ar3012 bluetooth adapter скачать драйвер windows 10