我尝试了官方演示代码:
#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)
它运行良好,但包装时:
pyinstaller --onefile test.py
然后运行test.exe,我得到了:
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
有什么我遗失的吗?
答案 0 :(得分:2)
添加&#39; engineio.async_gevent&#39;到spec文件中的hiddenimports。 你可以参考:https://github.com/miguelgrinberg/python-socketio/issues/35