0 votes
1 view
in Devops and Agile by (19.8k points)

I have a simple pandas pyinstaller exe which is over 40MB.

My exe example:

import collections

import csv

import selenium

import pandas


40MB+ for this seems a bit overkill.

How can I reduce this as much as possible?

One method:

pyinstaller --onefile --exclude matplotlib --exclude scipy --exclude pandas --exclude numpy.py

This, however, is not practical considering how big the exclusion list would be.

How do I select a folder for pyinstaller to get modules from and exclude everything else so I may have a small application?

Spec file:

a = Analysis(['123.py'],











pyz = PYZ(a.pure, a.zipped_data,


exe = EXE(pyz,










          console=True )

It's also worth mentioning. By default, Pyinstaller does not detect pandas.


hiddenimports = ['pandas._libs.tslibs.timedeltas']

To: C:\Users\<NAME>\AppData\Local\Programs\Python\Python36\Lib\site-packages\PyInstaller\hooks

1 Answer

0 votes
by (63.4k points)

For me, it was a simple case of using pandas were the size of the exe file is going to be huge.

Though removing certain directories was helpful, as it was UPXING that helped a lot too.

So there was an attribute that did all this, but for now, there is some manual handling involved because: multipackage-bundles is broken.


Now to the straightforward answer for various executables. If you have a lot of executable files, I highly recommend this approach:

pyinstaller -F abc.py --onedir (Contains all imports of both scripts)

pyinstaller -F abd.py --onedir (Contains all imports of both scripts)

Now place abd.exe in one directory of the abc.py folder as well as any other external scripts.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !