PyInstaller文件很大 [英] PyInstaller very big file size

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

问题描述

我已经使用wxPython创建了简单的代码编辑器.文件大小(python文件)为1.3 KB.但是,当我使用PyInstaller创建可执行文件时,会得到 30 MB文件!有没有办法减小文件大小?顺便说一句,我不是导入整个 wx 库,仅导入我需要的组件(例如from wx import Frame).

I've made simple code editor using wxPython. File size (python files) is 1.3 KB. But when I create executable using PyInstaller, I get 30 MB file! Is there a way to decrease file size? Btw, I am not importing whole wx library, only components I need (ex from wx import Frame).

使用Linux,Fedora 18 64位.

Using Linux, Fedora 18 64bit.

推荐答案

wxPython是一个很大的库,因此,当您创建可执行文件时,它们的最终容量通常在20到30 MB之间.还要注意,Python本身有点笨重,因为Python是一种解释语言.因此,在创建exe时,您还将包括Python解释器.

wxPython is a big library so when you create an executable, they tend to end up being between 20 and 30 MB. Also note that Python itself is kind of bulky because Python is an interpreted language. So you are also including the Python interpreter when you create the exe.

使用py2exe,我已将可执行文件控制在10 MB以下,但这很痛苦,并且不适用于所有项目.这实际上取决于您使用的是什么.您可以通过py2exe阅读我的历险

With py2exe, I have gotten the executable below 10 MB, but it's a pain and doesn't work for all projects. It really depends on what else you are using. You can read about my adventures with py2exe here.

使它变小的另一种方法是使用压缩程序.那有时行得通,有时却行不通.

The other way to get it smaller is to use a compression program. That sometimes works and sometimes doesn't.

您还可以告诉大多数这些二进制创建工具以排除项目.您也可以尝试.

You can also tell most of these binary creation tools to exclude items. You can try that too.

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

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