PyInstaller + PyQt5 + QML:未安装 QtQuick [英] PyInstaller + PyQt5 + QML: QtQuick is not installed
问题描述
我正在尝试使用 pyinstaller、PyQt5 和 qml(请参阅下面的文件)使用以下命令构建应用程序.
I'm trying to build an app using pyinstaller, PyQt5 and qml (see files below) using the following command.
pyrcc5 pyqt5_qml.qrc > pyqt5_qml_qrc.py
pyinstaller -w -F --noupx pyqt5_qml.py
(OSX 10.11.1、python 3.5.0、qt 5.5.1、pyinstaller 3.0)
(OSX 10.11.1, python 3.5.0, qt 5.5.1, pyinstaller 3.0)
pyqt5_qml.py 运行良好(打开Hello world!"窗口),但构建的应用程序抱怨模块QtQuick"2.4 版未安装
.我想该模块尚未包含在构建的应用程序中,但我不确定如何告诉 pyinstaller 这样做.
The pyqt5_qml.py runs fine (open an "Hello world!" window) but the built app complains about module "QtQuick" version 2.4 is not installed
. I guess the module has not been included into the built app but I'm not sure how to tell pyinstaller to do it.
pyqt5_qml.py:
pyqt5_qml.py:
import os, sys
from PyQt5 import QtCore, QtWidgets, QtQml
import pyqt5_qml_qrc
def main():
global app
app = QtWidgets.QApplication(sys.argv)
engine = QtQml.QQmlApplicationEngine()
engine.load(QtCore.QUrl('qrc:/hello.qml'))
root = engine.rootObjects()[0]
root.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
hello.qml:
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
ApplicationWindow {
title: qsTr("Window")
Rectangle {
width: 360
height: 360
Text {
anchors.centerIn: parent
text: "Hello World"
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}
}
pyqt5_qml.qrc:
pyqt5_qml.qrc:
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>hello.qml</file>
</qresource>
</RCC>
推荐答案
希望能帮到你
我遇到了同样的问题
下班后,我做了一些简单的事情,但对我来说却奏效了
After hours, I did something simple, but for me it worked
在我的 main.py 中,我指的是加载我添加的 QML 文件的文件
In my main.py I mean the file in which you load the QML file I added
import PyQt5.QtQuick
然后运行pyinstaller:
And then run pyinstaller :
pyinstaller -F - -onefile main.py
它奏效了
这篇关于PyInstaller + PyQt5 + QML:未安装 QtQuick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!