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/Azhurkral Mar 21 '26

Exactly, writing code is not my job, but I realized that implementing it would make my tasks so much faster, and is better if I do it myself than waiting for some guy on IT to develop it for me who knows when and how.

1

u/Yamoyek Mar 21 '26

Keep that spirit of tinkering! Hope you keep finding cool ways to automate things:)