Python 3.x + PyQt5 + py2exe / pyinstaller / cx-Freeze
I was looking into options for how to freeze my package that flask-desktop uses . Qt does a lot of the hard work, and as such it is a fairly large library.
I've been experimenting with several options to see what I can do. Python versions provide explicit support for each package.
| |Python 3.4|Python 3.5|Python 3.6|Runs* |Works**| |-----------------|----------|----------|----------|-------|-------| |PyQt4 |Yes |Yes |Yes |? |? | |PyQt5 (5.8.2) |No |Yes |Yes |Yes |Yes | |cx-Freeze (5.0.1)|Yes |Yes |Yes |Yes |Yes | |py2exe (0.9.2.2) |Yes |No |No |Yes |No | |pyinstaller*** |Yes |Yes*** |No |Yes |No |
* The command executes or imports the package without errors
** Command result is valid (i.e. creates a working freeze)
*** Supported in the dev branch
I have tried using the latest py2exe and pyinstaller with Python 3.4 / 3.5 / 3.6 separately with no success. The errors I get are different and complex each time, and my debugging and researching in it was unsuccessful for every pairing of Python version and freezer package. I won't have enough time to delve into this anytime soon.
PyQt4 is not a practical option as it lacks some very important features like HiDPI support and uses the legacy QtWebKit.
PyQt5 is only compatible with Python 3.5 and above because its package sip
requires it.
py2exe supports UPX and single file (.exe) output, but doesn't get past Python 3.4.
pyinstaller dev branch works in 3.5, but I couldn't get it to copy binaries to the output directory correctly. Every time I run it I get error messages about not being able to find the Qt5 libs. It's different every time you start.
cx-Freeze, on the other hand, works with some tutorial in setup.py
:
build_options = dict(
packages = ['encodings', 'asyncio', 'jinja2'],
...
)
Now this is great. It freezes the work, but my only problem is how to turn this 300MB folder of frozen files (70 files / folders!) Into something more manageable (ideally less than 30MB)? For example, all (precompiled) Qt5 libraries are copied to the destination twice, in two different paths: build\exe.win-amd64-3.6
and build\exe.win-amd64-3.6\PyQt5\Qt\bin
. I can remove the DLLs in build\exe.win-amd64-3.6
, and the program still works fine. And the dependency QtWebEngineCore.dll
weighs in at 65MB (uncompressed) and about 26MB after running through UPX at maximum compression -9
(that's a good start).
My goal is to keep the footprint of my application to a minimum, and currently my flash python program is hog memory:
My flash table program cramming memory lotta p>
What suggestions do you have for having a (Py) Qt5 based application using QtWebEngine to use less memory? Also, I am not familiar with cx-Freeze, so I would like to know if anyone can suggest how I can reduce the size of the build output, or how can I get another freezer to work with Python 3.5 / 3.6 and PyQt5 ...
I feel like I've explored a lot of options here, but I'm still running into difficult constraints due to incompatible Python / package version. Any help is appreciated.
source to share
No one has answered this question yet
See similar questions:
or similar: