gpt4 book ai didi

python - 如何使用 pyinstaller 打包 python flask_socketio 应用程序

转载 作者:太空宇宙 更新时间:2023-11-04 03:13:37 46 4
gpt4 key购买 nike

我尝试了官方的演示代码:

#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

有什么我想念的吗?

最佳答案

将“engineio.async_gevent”添加到规范文件中的 hiddenimports。您可以引用:https://github.com/miguelgrinberg/python-socketio/issues/35

关于python - 如何使用 pyinstaller 打包 python flask_socketio 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37087730/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com