r/pythonhelp • • Mar 19 '26

Need to turn a .py into a .exe

Hello, I am trying to turn a .py file into a .exe file with auto-py-to-exe so I can share it with my work colleagues that do not have python. The code is very simple, 30 lines of code and it only import 3 libraries: pandas, pathlib and openserver. It also does not do nothing very complex, it just retrieves data from a software and paste it in and excel, the .py file only weights 2kb.

The problem is that when I use auto-py-to-exe, the resulting exe ends up weighting 308MB, which doesn´t make any sense for me. It works, but a file of that size is absolutely impractical to use and share. It seems as it all the python libraries are loaded into the exe. I tried asking Copilot but it didn´t give me any useful solution.

Do you have any idea on what could be happening and why to fix it so the resulting exe is a light one?

Edit: after using openpyxl instead of pandas, I managed to reduce the size from 300mb to 35 mb, which is impressive. I will keep trying other metods to squiz it even more. Thank you all for your help!

24 Upvotes

84 comments sorted by

View all comments

Show parent comments

1

u/Worth-Wonder-7386 Mar 19 '26 edited Mar 19 '26

But this is how much of software is. Look at the size of different apps on your phone and even simple timer or note taking apps can be huge. 

1

u/OkSignificance5380 Mar 19 '26

This.

It's the cost of delivering software that "runs anywhere".

It's not an embedded environment, and so storage is cheap

I just downloaded chrome for Linux, which doesn't include the dependencies that it needs, and it's 122mb

Docker desktop is 500mb

Gitkraken (which I believe is electron based) is 300mb

Arduino ide, discord, and vscode all come at 100mb+

1

u/TW-Twisti Mar 19 '26

Right, I'm saying that's not a good thing that one should be proud of or happy about.

1

u/Pyromancer777 Mar 20 '26

It just isn't in the dev workstream to prioritize simplicity anymore. Back in the 80-90s, devs had to cram freaking everything into less than 100mb, most times even less. Floppy disks had storage capacity in kbs, not even mbs. Programmers had to think about every line of code to optimize where they could.

Now storage is cheap, devices are powerful, software devs are common, and companies want the same program packages to run on as many devices as possible. Bloat for the sake of broad compatibility is the norm.

When the constraints were, "if it isn't optimized, it won't run", everything was optimized. Now the constraints are, "we need 5 new features yesterday, and it has to work on literally a hundred types of device architecture", so taking the time for performance gains just isn't a priority.

1

u/stukalov_nz Mar 20 '26

I remember my floppys at 1.44MB!

1

u/Pyromancer777 Mar 20 '26

I remember the first games my parents got me on a computer (90s kid). I had to swap out like 4-5 different floppies just to install 1 game since they wouldn't fit on a single floppy. Now you could fit pretty much the entire library of all games from the 90s on just 1 thumb drive

1

u/TW-Twisti Mar 20 '26

I am with you in general, although I very much think we tipped way too hard towards the 'space/cpu time is cheap', which is why we essentially have to throw away phones after a few years now because a calculator app will cost you 300mb, your notes app comes in at 450mb and if you want to play an MP3, you better not have picked the 32gb model back in 2022; and why even the most simple software these days often still runs like absolute garbage like my god damn gallery app which does nothing but display thumbnails the same way my gallery on Windows 98 did takes like four seconds of me staring at it before it deigns to open a folder I tapped.

I think it would do our industry good if people were at least a little bit embarrassed about stuff like that again.

1

u/Pyromancer777 Mar 20 '26

I am 10000% on board with all of that. The problem is that most consumers don't care enough about performance as long as the app acts the way they expect it to and sadly not enough consumers are even in the age bracket that is aware of the performance drops over the years.

Basically, Millenials and younger Gen X are the only populations aware of how things used to run. The majority of Boomers and older Gen X don't even utilize current tech to the same degree as everyone else, plus they are likely more impressed with what devices can do now than they are dissatisfied with the losses of performance from the software.

Sure, your gallary app may take 4 seconds to load, but immediate feedback isn't a priority for the population who is mainly within retirement age and finally has more time on their hands.

Gen Z and Gen Alpha weren't even alive during the time when software had to be ultra performant to run, so that 4 second load time is their standard metric of comparison. They only know the tech as it exists right this moment, so they don't have reference for comparison.