egfconnor
egfconnor

Reputation: 2647

PyQt5 module "QtQuick" is not installed

I'm trying to get a basic PyQt5 QML project going using either Windows or Linux. I first tried Linux and with no luck am trying Windows now. My issue is whenever I try and run it via python main.py it will complain that "module "QtQuick" is not installed" and "module "QtQuick.Window" is not installed".

I feel like this is a simple pointing of some path to the QT install location but don't know where to go from here. Using Qt Widgets works but not QML.

My main.py file is:

import sys

from PyQt5.QtQml import QQmlApplicationEngine
from PyQt5.QtGui import QGuiApplication

def _find_plugins():
    import PyQt5
    from os import path
    paths = [path.abspath(path.join(path.dirname(PyQt5.__file__), 'plugins'))]
    import PyQt5.QtCore
    PyQt5.QtCore.QCoreApplication.setLibraryPaths(paths)

if __name__ == '__main__':
    # _find_plugins()

    app = QGuiApplication(sys.argv)

    engine = QQmlApplicationEngine()

    engine.load('test.qml')

    sys.exit(app.exec_())

and my test.qml file is:

import QtQuick 2.2
import QtQuick.Window 2.1

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    minimumWidth: 400
    minimumHeight: 300
}

Upvotes: 4

Views: 8094

Answers (2)

Morteza
Morteza

Reputation: 48

I faced this problem in Linux, and after playing around, I found out that by removing qt and pyqt5 with:

conda remove -c conda-forge pyside2 pyqt 

And installing those package with pip, my problem got solved! by using pip install pyqt5>=5.11

p.s: I am using: ubuntu 20.04, miniconda, python 3.7, pyqt5>=5.11

Upvotes: 1

egfconnor
egfconnor

Reputation: 2647

Turns out I needed to add the following Environment Variable:

QML2_IMPORT_PATH

with the value in my case being:

C:\Python35\Lib\site-packages\PyQt5\qml

Upvotes: 4

Related Questions