I’m currently working on an application that uses py2exe to make an exe file from a bit of Python code that utilizes matplotlib. It’s working pretty well except that my executables are massive. Running the conversion script below it creates 43.5 mb package (the exe and its dependencies). I know that there are probably some things that can be done to trim down the size of my application.
Any tips for cutting down the size of my application?
My conversion script:
from distutils.core import setup
import py2exe
import matplotlib
setup(
windows=[{'script': r'ElectronOrbitalGenerator.py'}],
data_files=matplotlib.get_py2exe_datafiles(),
options={r'py2exe':{r'includes': r'ElementConfig',
r'includes': r'ColorConv',
r'includes': r'Tkinter',
r'includes': r're',
r'includes': r'math',
r'includes': r'sys',
r'includes': r'matplotlib',
r'includes': r'mpl_toolkits',
r'dll_excludes': [r'MSVCP90.dll'],
}},
)
These are all the modules my program needs to run:
import ElementConfig, ColorConv
import Tkinter, re, math, sys
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
If you’re using matplotlib just to show some chart using default font etc you can just delete in
dist/mpl-datafolder all but matplotlib.conf and matplotlibrc.I did this and saved up abot 4MB on 12MB.
Why your dist is 43.5MB probably is not all due to matplotlib…