Reputation: 13
The libs which I use:
import os, sys
import subprocess
import shutil
from docx import *
from django.utils.encoding import smart_text
import xlrd
from pdfminer import *
import textract
import pandas as pd
from pptx import Presentation
from tika import parser
What can I do to reduce the exe size? My spec file:
a = Analysis(['tryhard.py'],
pathex=['C:\\poppler-0.67.0\\bin'],
binaries=[],
datas=[],
hiddenimports=['textract.parsers.txt_parser', 'textract.parsers.pdf_parser', 'textract.parsers.docx_parser', 'textract.parsers.odt_parser', 'pandas._libs.tslibs.timedeltas'],
hookspath=[],
runtime_hooks=[],
excludes=['numpy'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
Command pyinstaller -F --clean --onedir myspecfile.spec
generates 3 folders with 4GB size.
Upvotes: 1
Views: 245
Reputation: 38892
Look in the generated folders for things you don't need, then specify them in the excludes
line of your spec file. For example, I don't use Tcl, Tk or Tkinter, so my excludes
looks like:
excludes=['FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'],
Pyinstaller includes the kitchen sink, just in case. Anything that you can be sure is not needed can be excluded using excludes
. That will reduce the size (my final size for a one-file app is 63MB).
Here is a similar question about excludes
.
Upvotes: 1