Tag Archives: pyside2

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

The following error appears when pyside2 is running:
error content: this application failed to start because not Qt platform plugin could be initialized.reinstalling the application may fix this problem.

Solution one: this method once and for all.

Add the plugins/platforms in the path of pyside2 to the user variables in the system environment variables. My path is as follows:
the specific operation is as follows:


variable name: QT_ QPA_ PLATFORM_ PLUGIN_ Path
variable value: D:: (soft) Anaconda (LIB) site packages (pyside2) plugins (platforms)
different users have the same variable name, and the variable value varies with the file location
finally, after saving the variables, be sure to restart the computer, because the new environment variables will not be recognized by the system until they are restarted!

**

Solution 2:

**
add the following code in the initial part of the program:

dirname = os.path.dirname(PySide2.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

Code means to use temporary system environment variables, similar to solution one.