I have a simple pandas pyinstaller exe which is over 40MB.
My exe example:
import collections
import csv
import selenium
import pandas
print('hi')
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'],
pathex=['C:\\Users\\AA\\ZZ'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='123',
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True )
It's also worth mentioning. By default, Pyinstaller does not detect pandas.
Add:
hiddenimports = ['pandas._libs.tslibs.timedeltas']
To: C:\Users\<NAME>\AppData\Local\Programs\Python\Python36\Lib\site-packages\PyInstaller\hooks
A possible solution when using multiple executables, could be to link each executable to a separate folder or executable with all imports.
try setting up your environment with a virtualenv, and install in there only the required libraries
some details on working with virtual env are here: https://virtualenv.pypa.io/en/stable/