使用pyinstaller时过大的.exe文件

时间:2017-05-18 05:44:36

标签: python python-3.x executable pyinstaller

我已经对这个问题进行了一些搜索,人们抱怨可执行文件大小为30mb~100mb,但出于某种原因我的是300mb。我可能错了,但我认为这不正常。我尝试使用其他替代品,如cx_Freeze,但我得到了相同的结果。这是我在项目中的内容:

from PyQt5 import QtCore, QtGui, QtWidgets
from pyplot import functions as plot
if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(window)
    window.show()
    sys.exit(app.exec_())

pyplot是我项目的另一个python文件,包括:

from numpy import power, cbrt, sin, cos, arange
from matplotlib import pyplot as plt
from matplotlib import patches as pts
from scipy import integrate as intg

我使用此命令创建我的可执行文件:

pyinstaller --onefile --windowed montecarlo.py

感谢您的帮助

1 个答案:

答案 0 :(得分:2)

这是正常的,因为您导入的包具有一些大的传递依赖性。

要量化每个包的贡献,只需注释掉所有导入,运行pyinstaller,然后逐个添加它们,注意每个包后面的pyinstaller输出的大小。但是,您可能无法在统计数据中找到操作项,因为您的应用程序无论如何都需要每个导入项。