[英]Flask app is not running when pyinstaller is used with --noconsole
I have created a basic hello world application in flask. 我在flask中创建了一个基本的hello world应用程序。 Then I did
pyinstaller --noconsole main.py
. 然后我做了
pyinstaller --noconsole main.py
I have got main.exe file in /dist directory. 我在/ dist目录中有main.exe文件。 When I tried to run it, I am getting an alert of error showing Failed to execute script main
当我尝试运行它时,我收到一条错误提示,显示无法执行脚本主程序
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(debug=False)
Redirect stdout, either no nothing sys.stdout = sys.stderr = open(os.devnull, 'w')
or to file sys.stdout = open('file', 'w')
if you still want to be able to view its output at some stage 重定向stdout,或者什么都不重定向
sys.stdout = sys.stderr = open(os.devnull, 'w')
或到文件sys.stdout = open('file', 'w')
如果您仍然希望能够查看在某个阶段的输出
You can add the desired function to the top of your flask script 您可以在烧瓶脚本的顶部添加所需的功能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.