I want to build single-file executable on Windows 10 that uses pandas. Following is the totality of my single-file script TrivialTest.py
:
import numpy as np
import pandas as pd
np.random.seed(456)
j = [(a, b) for a in ['A','B','C'] for b in pd.date_range('2018-01-01', periods=5, freq='W')]
i = pd.MultiIndex.from_tuples(j, names=['Name','Num'])
df = pd.DataFrame(np.random.randn(15), i, columns=['Vals'])
df.to_csv('Test.csv')
Initial PyInstaller builds, whether --onefile
or --onedir
, produce .exe
files approaching 300MB in size.
Note here claims that running PyInstaller in a minimal python environment can get a trivial pandas script standalone .exe
under 20MB.
This claims to have gotten one to 15MB using pyinstaller --onefile --exclude matplotlib --exclude scipy --exclude pandas --exclude numpy --exclude IPython --exclude django
.
So I ran pyinstaller --onefile --exclude matplotlib --exclude scipy --exclude pandas --exclude numpy --exclude IPython --exclude django TrivialTest.py
, but the resulting dist\TrivialTest.exe
is still 237MB.
How can I whittle PyInstaller executables to a reasonable size?
E.g.:
- Is there a way I can figure out what PyInstaller is putting in the final
.exe
that I doubt is needed so that I can explicitly exclude it? If the answer has to do with the contents ofbuild\xref-trivialtest.html
I think I would be lost: That file alone is over 2.5MB! - Can I work from the other direction: Figure out independently exactly what is required and then tell PyInstaller to only include that?
- Am I just "doing it wrong?"