How to pack python flask_socketio app with pyinstaller
Question: I tried official demo code:

    
    
    #test.py
    from flask import Flask, render_template
    from flask_socketio import SocketIO
    
    app = Flask(__name__)
    app.config['SECRET_KEY'] = 'secret!'
    socketio = SocketIO(app)
    
    if __name__ == '__main__':
        socketio.run(app)
    

it runs well, but when packed with:

    
    
    pyinstaller --onefile test.py
    

and then run test.exe, I got:

    
    
    Z:\test\dist>test2.exe
    Traceback (most recent call last):
      File "<string>", line 6, in <module>
      File "site-packages\flask_socketio\__init__.py", line 119, in __init__
      File "site-packages\flask_socketio\__init__.py", line 144, in init_app
      File "site-packages\socketio\server.py", line 72, in __init__
      File "site-packages\engineio\server.py", line 100, in __init__
    ValueError: Invalid async_mode specified
    test2 returned -1
    

is there anything I am missing?


Answer: add 'engineio.async_gevent' to hiddenimports in spec file. you may refer to:
<https://github.com/miguelgrinberg/python-socketio/issues/35>

