[Python] Struggling with 5GB executable, How to optimize PyInstaller Packages?

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    I'm creating a python tool that uses PaddleOCR for text recognition. When I package it with PyInstaller, the executable is massive ~ 5GB. I've tried onedir mode, UPX compression, but it's still way too large.

    I asked AI agents to create me a pyinstaller spec file and it got my program down to 400-600MB in a couple of approaches, but I always encounter runtime errors because some modules are missing. Every time I add the missing module, another error appears with a different missing module - I assume I could repeat that process until I get no errors, but that feels like a stupid approach, there must be something better.

    How do I find out which large dependencies are being included unnecessarily? it's 2025 isn't there some tool that can analyze my code and generate an ideal PyInstaller spec file? PyInstaller docs just say "add modules to exclude" with the exclude parameter, but how do I know which ones ?

    I'm a complete beginner so I apologize if I got something completely wrong

    Continue reading...

Compartilhe esta Página