首页 > 解决方案 > 带有 PySide2 和 Pyinstaller 的应用程序在 linux 中生成 192MB 文件,但在 windows 中生成 70mb

问题描述

我正在使用 PyInstaller 制作一个独立的 PySide2 应用程序,但文件大小在 linux 上很大,在 windows 中 .exe 大小仅为 70mb 而在 linux 中为 192MB

在这两种情况下,构建都是使用仅具有必要模块的虚拟环境进行的。看起来问题出在 PySide2 上,因为带有标签的小窗口会生成 129.3 MB 的文件。有谁知道如何解决这个问题?

这是 pyinstaller 产生 129.3 MB 的 MWE:

import sys
from PySide2.QtWidgets import QApplication, QLabel

# Create a Qt application
app = QApplication(sys.argv)
# Create a Label and show it
label = QLabel("Hello World")
label.show()
# Enter Qt application main loop
app.exec_()
sys.exit()

信息:

窗户 10

linux薄荷19.2

linux上的python 3.7.5 64位

windows上的python 3.7.4 32位

pyinstaller:4.0.dev0+a9b299995

PySide2:5.13.0

命令:../venv/bin/pyinstaller --onefile mwe.py

编辑1:

我检查了 pyside2 在 windows 和 linux 中的大小,它在 linux 中要重得多,超过 450 mb,而在 windows 中它只有 300 Mb

标签: pythonlinuxpyinstallerpyside2

解决方案


推荐阅读