On my Windows 10 machine I'm trying few simple examples of new Qt6 and QML based example doesn't work for me.
I'm running Python 3.8.6 and a virtual env
python3 -m venv venv
.\venv\Scripts\Activate.ps1
The pyside6 installs without any warnings into the venv
pip install pyside6
and a non-QML hello world example using QApplication and QLabel runs fine (this one: https://doc.qt.io/qtforpython/tutorials/basictutorial/widgets.html )
What doesn't work is this example, taken from https://doc.qt.io/qtforpython/tutorials/basictutorial/qml.html :
main.py:
from PySide6.QtWidgets import QApplication
from PySide6.QtQuick import QQuickView
from PySide6.QtCore import QUrl
app = QApplication([])
view = QQuickView()
url = QUrl("view.qml")
view.setSource(url)
view.show()
app.exec_()
view.qml:
import QtQuick 2.0
Rectangle {
width: 200
height: 200
color: "green"
Text {
text: "Hello World"
anchors.centerIn: parent
}
}
the messages I receive trying to run are:
file:///C:/github/aorcl/python-gui-2/view.qml:1:1: Cannot load library C:\github\aorcl\python-gui-2\venv\lib\site-packages\PySide6\qml\QtQml\WorkerScript\workerscriptplugin.dll: The specified module could not be found.
import QtQuick
^
file:///C:/github/aorcl/python-gui-2/view.qml: Failed to load dependencies for module "QtQml" version 6.0
file:///C:/github/aorcl/python-gui-2/view.qml: Failed to load dependencies for module "QtQuick" version 6.0
I verified and the file isn't missing, it is there:
C:\github\aorcl\python-gui-2\venv\lib\site-packages\PySide6\qml\QtQml\WorkerScript\workerscriptplugin.dll
What else am I missing?
I have the same error using Python 3.9.1 + Pipenv + Windows 10 + Powershell. Maybe it's something related to the system PATH environment variable.
I tried with venv and CMD (not Powershell) then but activating the environment with .env\Scripts\activate.bat
instead of .\env\Scripts\Activate.ps1
. It's working
My environment is Python3.8
+ PySide6
+ Pycharm
in win10
.
I Changed import QtQuick 2.0
to import QtQuick 6.0
. It's working.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.