QML 图形效果不适用于 PyInstaller

QML Graphical Effects not working with PyInstaller

当我使用 PyInstaller 4.1 捆绑我的 PySide2 QML 应用程序时。不会呈现任何图形效果。我在下面有一个 LinearGradient 不起作用的示例。

main.qml

import sys
import os

from PySide2.QtGui import QGuiApplication
from PySide2.QtQml import QQmlApplicationEngine


if __name__ == "__main__":
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())

main.py

import QtQuick 2.15
import QtQuick.Window 2.15
import QtGraphicalEffects 1.15

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    Item {
        width: 300
        height: 300

        LinearGradient {
            anchors.fill: parent
            start: Qt.point(0, 0)
            end: Qt.point(0, 300)
            gradient: Gradient {
                GradientStop { position: 0.0; color: "white" }
                GradientStop { position: 1.0; color: "black" }
            }
        }
    }
}

当我 运行 这个简单的 pyinstaller 命令成功时,没有任何错误:

pyinstaller main.py

ubuntu@ubuntu:~/Projects/build_test$ pyinstaller main.py
22 INFO: PyInstaller: 4.1
22 INFO: Python: 3.7.3
23 INFO: Platform: Linux-5.0.0-23-generic-x86_64-with-Ubuntu-19.04-disco
23 INFO: wrote /home/ubuntu/Projects/build_test/main.spec
24 INFO: UPX is not available.
25 INFO: Extending PYTHONPATH with paths
['/home/ubuntu/Projects/build_test', '/home/ubuntu/Projects/build_test']
30 INFO: checking Analysis
30 INFO: Building Analysis because Analysis-00.toc is non existent
30 INFO: Initializing module dependency graph...
31 INFO: Caching module graph hooks...
35 INFO: Analyzing base_library.zip ...
1820 INFO: Caching module dependency graph...
1871 INFO: running Analysis Analysis-00.toc
1893 INFO: Analyzing /home/ubuntu/Projects/build_test/main.py
1937 INFO: Processing module hooks...
1937 INFO: Loading module hook 'hook-xml.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2089 INFO: Loading module hook 'hook-PySide2.QtQml.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2257 INFO: Loading module hook 'hook-encodings.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2291 INFO: Loading module hook 'hook-difflib.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2292 INFO: Excluding import of doctest from module difflib
2292 INFO: Loading module hook 'hook-PySide2.QtCore.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2341 INFO: Loading module hook 'hook-PySide2.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2356 INFO: Loading module hook 'hook-heapq.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2357 INFO: Excluding import of doctest from module heapq
2357 INFO: Loading module hook 'hook-pickle.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2358 INFO: Excluding import of argparse from module pickle
2358 INFO: Loading module hook 'hook-PySide2.QtNetwork.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2407 INFO: Loading module hook 'hook-PySide2.QtGui.py' from '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks'...
2476 INFO: Looking for ctypes DLLs
2476 INFO: Analyzing run-time hooks ...
2478 INFO: Including run-time hook '/home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pyside2.py'
2481 INFO: Looking for dynamic libraries
7130 INFO: Looking for eggs
7131 INFO: Python library not in binary dependencies. Doing additional searching...
7190 INFO: Using Python library /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
7193 INFO: Warnings written to /home/ubuntu/Projects/build_test/build/main/warn-main.txt
7207 INFO: Graph cross-reference written to /home/ubuntu/Projects/build_test/build/main/xref-main.html
7248 INFO: checking PYZ
7248 INFO: Building PYZ because PYZ-00.toc is non existent
7248 INFO: Building PYZ (ZlibArchive) /home/ubuntu/Projects/build_test/build/main/PYZ-00.pyz
7476 INFO: Building PYZ (ZlibArchive) /home/ubuntu/Projects/build_test/build/main/PYZ-00.pyz completed successfully.
7477 INFO: checking PKG
7477 INFO: Building PKG because PKG-00.toc is non existent
7477 INFO: Building PKG (CArchive) PKG-00.pkg
7499 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
7500 INFO: Bootloader /home/ubuntu/.local/lib/python3.7/site-packages/PyInstaller/bootloader/Linux-64bit/run
7500 INFO: checking EXE
7500 INFO: Building EXE because EXE-00.toc is non existent
7500 INFO: Building EXE from EXE-00.toc
7500 INFO: Appending archive to ELF section in EXE /home/ubuntu/Projects/build_test/build/main/main
7504 INFO: Building EXE from EXE-00.toc completed successfully.
7507 INFO: checking COLLECT
7507 INFO: Building COLLECT because COLLECT-00.toc is non existent
7507 INFO: Building COLLECT COLLECT-00.toc
7967 INFO: Building COLLECT COLLECT-00.toc completed successfully.

这是 /dist 中所有文件和目录的列表: https://pastebin.com/raw/2XMmi2yi

以下是 运行 应用 QT_DEBUG_PLUGINS=1 后的输出: https://pastebin.com/raw/fHG1th1u

我已经尝试在两个不同的系统上执行此操作,结果相同。

此问题已在 PyInstaller 中得到解决。我提交了错误,开发人员修复了它。