Reputation: 171
I use python version 3.11.1 in a virtual env and used pip install pyside6
to install pyside6
The full error I get is:
QQmlApplicationEngine failed to load component
file:///E:/project_path/gui_pyside6/first_gui/virenv/src/main.qml:1:1: Cannot load library E:\project_path\gui_pyside6\first_gui\virenv\Lib\site-packages\PySide6\qml\QtQuick\qtquick2plugin.dll: The specified module could not be found.
I have checked and qtquick2plugin.dll is in that folder. I even added the path to my environment paths, but nothing seems to solve it. How can I solve this?
This is my main.py
import sys
from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.quit.connect(app.quit)
engine.load('main.qml')
sys.exit(app.exec())
This is my main.qml
import QtQuick 2.15
import QtQuick.Controls 2.15
ApplicationWindow {
visible: true
width: 600
height: 500
title: "HelloApp"
Text {
anchors.centerIn: parent
text: "Hello World"
font.pixelSize: 24
}
}
Platform: Windows 10
Upvotes: 1
Views: 780
Reputation: 19
Your solution of installing PyQt6 and importing PyQt6.QtCore works. However, the entire point of using PySide6 is to avoid using Qt due to licensing. It is a total showstopper that PySide6 cannot run the first example without installing PyQt6.
I changed over the PySide6 imports to be PyQt6 and it runs perfectly. I uninstalled PySide6 completely from the venv and it still runs.
I also removed the import PyQt6.QtCore from the main.py because it was showing as not referenced and it still runs. It would not run without that using PySide6, even though it was still showing as not referenced, this shows something is very wrong with PySide6. This early in looking at it, I'm forced to conclude PySide6 is not a viable alternative to PyQt6.
Upvotes: 0
Reputation: 11
Try installing PyQt6:
pip install PyQt6
then add to main.py:
import PyQt6.QtCore
Upvotes: 1