second update:
Since I cannot put comments yet (not enough contributions on stackoverflow?) I am adding this update to say that I tried the hook-based solution (which, in theory is the best way to deal with this sort of problem), but like Sören reported, this did not seem to get flask-compress into the distribution.
update:
The monkey-patching solution is clearly preferable, both because it leaves the flask code intact (and apparently the original functionality), but also because it (presumably) identifies the true underlying problem -- flask-compress is being brought along for the ride but simply isn't detected by pkg_resources... I wonder what (if anything) can be done to generalize this -- it may be possible to modify pkg_resources to work in a "bundled" Pyinstaller context.
original post:
I got hit with the exact same problem. Now, the "correct" thing to do is to figure out the apparently subtle way to add a proper Pyinstaller hook to take care of this issue. Maybe I will get around to doing that at some point -- certainly, what you tried to do makes sense and should've worked. I did the even more basic move of explicitly importing flask_compress in the main python script, without success.
However, since we are both trying to Pyinstallerize a flask-dependent (desktop) application, chances are very good that neither of us actually needs to gzip the responses that are being generated, so it is possible to eliminate the whole problem by "simplifying the software a bit". In my case, the references to flask_compress came from dash, so I ripped out the gzip functionality (found in Lib/site-packages/dash/dash.py
). The key relevant references are on lines 21, 53, 292, 321 and 432.
"Rewire" references like those (in whatever library you use which references flask-compress) and all your problems magically disappear -- worked for me :-)
My bet is that line 53 engages machinery that is too clever/dynamic for Pyinstaller. Don't get me wrong -- Pyinstaller is nothing short of a miracle but as a community we will be forever running around trying to plug these clever-hacks because Python simply was not made to generate nice standalone executables.