3

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?

  • The library loading failure doesn't necessarily mean that the file isn't there. It looks as if you were mixing 32 and 64 bit binaries. Make sure that the Python you're using is the same bitness as the Qt you installed. – Kuba hasn't forgotten Monica Dec 23 '20 at 20:39
  • @UnslanderMonica I only installed PySide6 by pip and nothing else (there is no separate Qt installation on this machine). What makes you think there is a bitness problem? Basic Qt things are working - it's the QML file that doesn't? – Alexey Dolganov Dec 24 '20 at 09:27
  • @UnslanderMonica I just verified and both the Python I'm using and the PySide6 DLLs that I find in venv\Lib\site-packages\PySide6 are 64 bit... – Alexey Dolganov Dec 24 '20 at 09:52
  • I just tried 3.8.5 and 3.9.1 with fresh environments in my windows 10 and both work without problem. Can you share the terminal you are using to launch the example, or if you are using an IDE? can you share the content of your PATH environment variable? maybe you have other Qt installations that are somehow interfering with your application. – cmaureir Jan 20 '21 at 08:44

2 Answers2

0

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

crisconru
  • 170
  • 2
  • 7
0

My environment is Python3.8 + PySide6 + Pycharm in win10.

I Changed import QtQuick 2.0 to import QtQuick 6.0. It's working.

SACell
  • 1