减少 pyinstaller 可执行文件的大小 [英] Reduce pyinstaller executable size

查看:89
本文介绍了减少 pyinstaller 可执行文件的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只有一行代码 input() 是用 python 编写的,并与带有选项 --onefile 的 pyinstaller 打包在一起.exe 文件是 4577 kB,几乎是 5Mb.如何减小其大小或排除一些自动捆绑的库?

I have only one line of code input() written in python and packed with pyinstaller with option --onefile. The exe file is 4577 kB which is almost 5Mb. How can I reduce its size or exclude some auto-bundled libraries?

推荐答案

您使用 pyinstaller 创建的 .exe 文件包括 python 解释器和脚本中包含的所有模块.也许,您使用的模块本身就有一个很大的库.然而,您可以尝试使用 py2exe 但它可能不适用于所有项目.另一种缩小它的方法是使用压缩程序,使用 UPX 压缩可执行文件(看看这个:http://htmlpreview.github.io/?https://github.com/pyinstaller/pyinstaller/blob/v2.0/doc/Manual.html#a-note-on-using-upx).您也可以尝试排除某些项目,但请自行决定删除此类项目不会影响 .exe 的功能.

The .exe file you create using pyinstaller includes the python interpreter and all modules included in your script.Maybe, the modules you are using have a big library themselves. You can however try using py2exe but it might not work for all projects.The other way to get it smaller is to use a compression program as like, compress the executable using UPX (have a look at this:http://htmlpreview.github.io/?https://github.com/pyinstaller/pyinstaller/blob/v2.0/doc/Manual.html#a-note-on-using-upx). You can also try excluding some items too but at the discretion that removing such items doesn't interfere with the functionality of your .exe.

这篇关于减少 pyinstaller 可执行文件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆