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/Reddigestion Mar 19 '26

Ok, so that was your insult keyboard warrior, so why not take the time to explain why not?

1

u/wakeupandshave Mar 19 '26

it might take your Shmaude a bit of time to re-write pandas

1

u/Snatchematician Mar 19 '26

It doesn’t need to rewrite pandas, it just needs to implement the handful of operations OP needs (probably just a groupby or sum) directly.

1

u/Pyromancer777 Mar 20 '26

Pretty much this. Python is neat and tidy at the cost of performance and environment dependencies. C++ can do everything Python can, but the lower-level code allows for way more performance gains and size reduction. If you prompt the AI well enough, it will basically just recreate the functionality of the needed bits from the Pandas library without having to pull in the entire library

1

u/LavishnessWest8159 Mar 20 '26

A 30 lines of python could become a few hundred lines of assembly real quick in 2026, depending on dependency calls.

1

u/Snatchematician Mar 20 '26

Oh no, hundreds of lines of assembly! How will we cope?