PyQt5模块"QtQuick"未安装 [英] PyQt5 module "QtQuick" is not installed
问题描述
我正在尝试使用Windows或Linux获得一个基本的PyQt5 QML项目.我首先尝试过Linux,但现在运气不佳,我正在尝试Windows.我的问题是,每当我尝试通过python main.py运行它时,都会抱怨未安装模块"QtQuick"和未安装模块" QtQuick.Window.
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".
我觉得这只是指向QT安装位置的一些简单路径,但不知道从这里到哪里.使用Qt窗口小部件有效,但不能使用QML.
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.
我的main.py文件是:
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_())
我的test.qml文件是:
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
}
推荐答案
原来,我需要添加以下环境变量:
Turns out I needed to add the following Environment Variable:
QML2_IMPORT_PATH
在我的情况下,值为:
C:\Python35\Lib\site-packages\PyQt5\qml
这篇关于PyQt5模块"QtQuick"未安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!