I just installed PySide2 with pip in my base environment and, when I tried to run an application, I got the following error:
qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: direct2d, minimal, offscreen, webgl, windows.
I then created a venv and installed PySide2 and the application runs, but I'd like to understand what causes this error and how I can fix it.
What I tried to run is a very simple window with no widgets yet.
from PySide2.QtWidgets import (QApplication, QLabel, QVBoxLayout, QPushButton,
QWidget, QGridLayout, QTabWidget, QListWidget,
QListWidgetItem, QCheckBox, QHBoxLayout,
QHBoxLayout, QLineEdit, QDialog, QMessageBox,
QStyle, QStyleOption, QStylePainter,
QStackedWidget, QScrollArea, QComboBox,
QDoubleSpinBox)
from PySide2 import QtCore, QtWidgets
from PySide2.QtCore import QRect, QPoint, QSettings, QSize, QProcess, Qt
class Window(QWidget):
def __init__(self):
super().__init__()
self.setStyleSheet('''
''')
self.setWindowTitle('Some title')
self.screen = QApplication.primaryScreen()
rect = QRect(QPoint(), self.screen.size() * 0.9)
rect.moveCenter(self.screen.geometry().center())
self.setGeometry(rect)
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())