Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overly large .exe file when using pyinstaller

I've searched a little bit about this problem where people complained about the executable file size being 30mb ~ 100mb, but for some reason mine is 300mb. I may be wrong, but I don't think this is normal. I tried using other alternatives like cx_Freeze, but I get the same result. Here's my includes in my project :

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 is another python file for my project which include :

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

I use this command to create my executable :

pyinstaller --onefile --windowed montecarlo.py

Thanks for helping

like image 367
Drakota Avatar asked May 18 '17 05:05

Drakota


1 Answers

This is normal, as the packages you import have some large transitive dependencies.

To quantify each package's contribution, simply comment out all the imports, run pyinstaller, then add them back one by one, noting the size of pyinstaller's output after each one. You probably won't find an action item in the stats, though, since your app needs each of those imports anyway.

like image 166
J_H Avatar answered Oct 24 '22 14:10

J_H