1

Ever since updating to the most recently released QGIS stable version, 3.14.15, I am getting the error pop-up window:

"This application failed to start because no Qt platform plugin could be initialized..."

I have doublechecked the contents of the Qt platform pathway (C:\OSGeo4W64\apps\Qt5\plugins\platforms) and do have all 4 DLLs. After hitting a brick wall I eventually performed a complete uninstall and reinstall of QGIS 3.14 but am still unable to open QGIS with Python for either stable or nightly releases.

Any help would be great.

mastorey
  • 449
  • 1
  • 4
  • 19

1 Answers1

4

I just installed QGIS 3.10 for the first time on Windows and when I tried to run it with Python I got exactly the same error message. I fixed it by explicitly setting the QT_QPA_PLATFORM_PLUGIN_PATH environment variable.

You can check if this is your problem too by running the following command in your Python script:

import os
print(os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'])

If those commands do not give you a file path you most likely have the same problem. In my case I fixed it by modifying the beginning of my Python script as follows:

import os
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = '<qgis install location>\\apps\Qt5\plugins'

where < qgis install location > is the file path where QGIS is installed on my system, in my case 'C:\Program Files\QGIS 3.10'. It is also possible to set the same variable using the normal environment variables options for whatever platform you're using, or with a batch file.