[英]Why is my exe script so heavy? (Pyinstaller)
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?我能做些什么来减少 exe 的大小? 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.命令pyinstaller -F --clean --onedir myspecfile.spec
生成 3 个 4GB 大小的文件夹。
Look in the generated folders for things you don't need, then specify them in the excludes
line of your spec file.在生成的文件夹中查找不需要的内容,然后在规范文件的excludes
行中指定它们。 For example, I don't use Tcl, Tk or Tkinter, so my excludes
looks like:例如,我不使用 Tcl、Tk 或 Tkinter,所以我的excludes
项如下所示:
excludes=['FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'],
Pyinstaller includes the kitchen sink, just in case. Pyinstaller 包括厨房水槽,以防万一。 Anything that you can be sure is not needed can be excluded using excludes
.您可以确定不需要的任何内容都可以使用excludes
。 That will reduce the size (my final size for a one-file app is 63MB).这将减小大小(我的单文件应用程序的最终大小是 63MB)。
Here is a similar question about excludes
. 这是关于excludes
的类似问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.