Python Forum
Pyinstaller question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pyinstaller question
#1
Hi,
My app slowly evolves into new versions, never any big changes.
I then proceed to make a new exe, always in the same manner:
Output:
pyinstaller --clean --onefile --windowed VVX-V6.py
I always get the approx same filesize for the exe: +/- 102 mb.

Today, i saw that the filesize of the exe was over 500 mb.
I had noticed a lot of comments about tensorflow in the verbose
pyinstaller analysis. There is no tensorflow import in the app !

So I proceded to pip uninstall every pckage that had the word "tensor" in it,
and ran the pyinstaller again. This time the size was only 200mb.
Still a lot more than I expect. But, everything is working fine.

Where do I start to analyse what unnecessary elements pyinstaller is
incorporating into the app exe ?
thx,
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#2
I have proceeded to pip unistall a series of packages that I
had installed out of intrest, but am not using in the app.
The exe keeps getting smaller and smaller, now even smaller that what I am used to.
And - not unimportant- it still works.

So the question is, why does pyinstaller collect packages that
are not relevant to the app?
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#3
Here are some steps you can take to analyze and reduce the size of your app:

Use the --debug flag: Run PyInstaller with the --debug flag to see detailed output, which can help identify what modules are being included.

Inspect the build folder: After running PyInstaller, check the build folder. It contains logs that show which modules and dependencies are included. Look for any unexpected packages or libraries.

Check the .spec file: Modify your .spec file to exclude unnecessary modules explicitly. You can use the exclude parameter to prevent specific libraries from being included.

Analyze dependencies: Use tools like pipdeptree to visualize your project's dependencies. This can help you identify any unwanted packages that might be pulled in by other libraries. Utilizing it support for nonprofit organizations organizations is crucial in optimizing operations and managing resources effectively. With reliable IT services, nonprofits can enhance data security, streamline communication, and improve project management, allowing them to focus on their core mission and serve their communities better.

Reduce package usage: Sometimes, certain libraries come with heavy dependencies. If you're using libraries that include TensorFlow or similar, consider lighter alternatives if applicable.

Test in a clean environment: Create a virtual environment with only the essential packages for your app and build the executable from there. This minimizes the chance of including unnecessary libraries.
Reply
#4
I also had similar experiences with pyinstaller (in Linux). Too many unnecessary modules.
Nuitka does it better.
Reply
#5
To Axel & Bronjer.
Thanks for the advice. I will surely look into those suggestions.
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pyinstaller question DPaul 3 4,088 Nov-01-2022, 11:10 AM
Last Post: carecavoador

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020