QtQuick Python+Anaconda: "main.qml:1 module "QtQuick" version 2.14 is not installed"
-
I'm trying to run a QtQuick application using python and Anaconda manager in a CMD terminal (Windows):
python main.py
but I get the error:
file:///C:/Users/user/Documents/code/QT/QtQuickPy/main.qml:1 module "QtQuick" version 2.14 is not installed
I have Python 3.7 with PySlide2 and PyQT installed. I tried setting up the environment variables for QT:
Path=...; C:\Qt\Tools\mingw900_64\bin QTDIR=C:\Qt\6.2.2\mingw_64
-
Hi,
Why are you pointing your environment that use PySide2 which uses Qt 5 to your Qt 6 installation ?
-
Hi,
Why are you pointing your environment that use PySide2 which uses Qt 5 to your Qt 6 installation ?
@SGaist Yeah good point, didn't notice that. But in any case, I tried installing Qt5 (in addition to the initial Qt6 install). So supposedly I have now both.
However, when I create a Python Project, there is no option to choose which Qt version I want (as opposed to Cpp Project, where such option appears). So I thought maybe it didn't matter. In any case I will try to change that variable...
-
Do you actually have PySide2 installed ?
If so, how ? -
@SGaist Yes, I installed using
conda install -c conda-forge pyside2
, and it installedpyside2-5.13.2
. -
Without your environment variable manipulation, are you able to start your script ?
-
@SGaist Not at all
Just an update, I added the following environment variables:QTDIR=C:\Qt\5.15.2 QML_IMPORT_PATH=C:\Qt\5.15.2\mingw81_64\qml QML2_IMPORT_PATH=C:\Qt\5.15.2\mingw81_64\qml
And now I'm getting a new error, which is more promising:
QQmlApplicationEngine failed to load component file:///C:/Users/User/OneDrive/Documents/code/QT-Projects/QtQuickPy/main.qml:1 plugin cannot be loaded for module "QtQuick": The plugin 'C:/Qt/5.15.2/mingw81_64/qml/QtQuick.2/qtquick2plugin.dll' uses incompatible Qt library. (5.15.0) [release]
I suppose now I just need to find the correct version permutation of Python+Pyside+PyQT+Qt+Qt Quick.
Do you have any idea if there is a table about this somewhere?
For the record, my current config is:
Python 3.7 (from anaconda environment) - pyside2 5.13.2 - qt 5.12.9 (was installed automatically with `conda install pyside2`) QT 5.15.1 (from C:\Qt\5.15.1) QT Quick 2.14 (from the qml file)
(I'm guessing the issue is QT 5.15.1 and Python Qt 5.12.9 yeah? Even though the error mentions incorrect QtQuick version...)
-
Ok, I solved the problem, it was incompatibility between QtQuick version and the installed Pyside2 version.
I got it to work without setting up environment variables by using Python 3.8 and Pyside 5.15 (and QtQuick 2.14).
Changing the QtQuick version to something like 2.1 caused the first set up with the earlier version of Pyside to work as well.
It's a bit confusing because nowhere is explained which version of Pyside2 is compatible with which version of QtQuick... There is a table here from the docs, but it doesn't mention Pyside
-
PySide2 releases follow the Qt 5 releases.