9 Replies - 13948 Views - Last Post: 01 July 2018 - 09:45 AM Rate Topic: -----

#1 Eric115   User is offline

  • coderさん
  • member icon

Reputation: 63
  • View blog
  • Posts: 698
  • Joined: 19-January 09

making smaller exe files

Posted 21 August 2010 - 06:18 PM

Hi all,
You may remember a few weeks ago I asked about making a single exe file with no GUI file. Well I figured that out, but when I make the file into an exe, it becomes heaps bigger than the script file. The .py file I am converting is 10kb big and when I make it an exe file it goes to 8.5mb! If I use upx to zip it, it goes down 8.3mb. Before I added in the resource to the file, it was about 8kb and came out as 7.4mb. When the file came out this big I tried changing it so that I only imported the bits I used from modules and nothing more and it didn't help at all. I do understand that the exe file might be somewhat bigger than the script file but I was expecting maybe 1mb at max. Does anyone know why the file is so big? Or even better how I can make it smaller? This is my import list:
from PythonCard.components import button, statictext
from PythonCard import dialog, model
import wx, os, sys, shutil, FileNumber


FileNumber is a custom module I made (it's in the python tutorials if you want to see it or click here)
Thanks in advance.
p.s. I am using pyinstaller to make the exe file

Is This A Good Question/Topic? 0
  • +

Replies To: making smaller exe files

#2 SpeedisaVirus   User is offline

  • Baller

Reputation: 115
  • View blog
  • Posts: 855
  • Joined: 06-October 08

Re: making smaller exe files

Posted 23 August 2010 - 10:03 AM

I've not used it but knowing what I know of pyInstaller, it is likely so large because it is including files required to make this script work on multiple platforms that may or may not have python installed. There are a lot of libraries and such that would get packed in there beyond your script to make that possible.
Was This Post Helpful? 1
  • +
  • -

#3 Eric115   User is offline

  • coderさん
  • member icon

Reputation: 63
  • View blog
  • Posts: 698
  • Joined: 19-January 09

Re: making smaller exe files

Posted 24 August 2010 - 04:06 AM

Thanks for the reply. Do you know if there is anyway I can make the files smaller? I am looking at programs (possibly written in C or C++) that are less than a MB big and do heaps more stuff than my simple program. Do they run off a built in windows library? Or are there platforms just smaller?
Thanks again
Was This Post Helpful? 0
  • +
  • -

#4 Oler1s   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1397
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: making smaller exe files

Posted 24 August 2010 - 10:31 AM

There is no implementation of Python that compiles to native executables. What py2exe and pyinstaller do is create a bundle of the interpeter, your code, and dependencies. It's so many MB big because that's what it takes to bundle the entire runtime.
Was This Post Helpful? 1
  • +
  • -

#5 Eric115   User is offline

  • coderさん
  • member icon

Reputation: 63
  • View blog
  • Posts: 698
  • Joined: 19-January 09

Re: making smaller exe files

Posted 26 August 2010 - 05:11 AM

Thanks for the replies I understand why they are so big now
Was This Post Helpful? 0
  • +
  • -

#6 AMER~NBC   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 20-May 11

Re: making smaller exe files

Posted 20 May 2011 - 06:13 AM

One thing that would be interesting to see is if the executable has a 'floor' of sorts. Perhaps the 8 Mb size is just the initial build and your code is just added to it. When your code starts to get a bit bigger the difference in size is only that of the sources size and the eight or so megabytes is just an initial value. This is probably only correct to a certain extent however.
Was This Post Helpful? 0
  • +
  • -

#7 atraub   User is offline

  • Pythoneer
  • member icon

Reputation: 833
  • View blog
  • Posts: 2,259
  • Joined: 23-December 08

Re: making smaller exe files

Posted 20 May 2011 - 11:27 AM

I suppose there's no harm in throwing my 2 cents into this ol' post. Have you considered using Cython? It can be compiled and would likely be smaller.

For the record:
DIC does NOT have a policy against necroposting so long as your post is relevant and adds to the discussion. I tend to agree. Better late than never, right?

This post has been edited by atraub: 20 May 2011 - 11:29 AM

Was This Post Helpful? 1
  • +
  • -

#8 Eric115   User is offline

  • coderさん
  • member icon

Reputation: 63
  • View blog
  • Posts: 698
  • Joined: 19-January 09

Re: making smaller exe files

Posted 20 May 2011 - 09:36 PM

Thanks, I had a brief look at Cython before and I thought it was discontinued, but that may have been something else... Anyway, next time I need to compile a program, I'll look into it thanks.

P.s. After doing more compiling, I realized that the file has a base size of about 8mb and then doesn't get much larger when you add more stuff in.
Was This Post Helpful? 0
  • +
  • -

#9 Ismael_Safadi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-July 18

Re: making smaller exe files

Posted 01 July 2018 - 09:04 AM

hi all , anyone find a solution for this problem ?
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15319
  • View blog
  • Posts: 61,433
  • Joined: 12-June 08

Re: making smaller exe files

Posted 01 July 2018 - 09:45 AM

@Ismael_Safadi - the topic is about seven years old. Perhaps create a new one explaining what you are doing, what isn't working, and what you have tried.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1