Putting py2exe and matplotlib on a diet

I am currently working on an application that uses py2exe to make an exe file from a small Python code that uses matplotlib. It works very well, except that my executables are massive. Performing the conversion script below, it creates 43.5 MB of the package (exe and its dependencies). I know that there are some things that can be done to reduce the size of my application.

Any tips on reducing 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 that my program should execute:

 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 
+4
source share
1 answer

If you use matplotlib to show any chart using the default font, etc., you can simply delete everything except matplotlib.conf and matplotlibrc in the dist/mpl-data folder.

I did this and accumulated abot 4MB at 12MB.

Why is your dist 43.5MB probably not all because of matplotlib ...

+6
source

Source: https://habr.com/ru/post/1340144/


All Articles