简体   繁体   English

pyinstaller flask app致命错误运行.exe

[英]pyinstaller flask app fatal error running .exe

I am looking at this blog post for creating an executable file to run a flask app on Windows. 我正在看这篇博客文章 ,创建一个可执行文件来在Windows上运行烧瓶应用程序。 Question, would this be useful if there was a standalone app created for people using that app that were not very computer technical? 问题,如果有一个独立的应用程序为使用该应用程序而不是非常计算机技术的人创建,这会有用吗? IE, just run the .exe file to open up the app on a localhost web browser versus opening up the command prompt to run a typical flask server... IE,只需运行.exe文件在localhost Web浏览器上打开应用程序,而不是打开命令提示符来运行典型的flask服务器...

Im just experimenting with this and I pip install pyinstaller as the blog post mentioned, and ran this command pyinstaller -w -F hello.py across my test flask code directory. 我正在试验这个,我将pip install pyinstaller作为博客文章提到,并在我的测试烧瓶代码目录中运行此命令pyinstaller -w -F hello.py

from flask import Flask


app = Flask(__name__)

@app.route('/')
@app.route('/index')
def index():
    return "Hello, World!"


if __name__ == '__main__':
    app.run(debug=True)

Pyinstaller seems to execute everything correctly at least it doesn't look like there are any errors compiling. Pyinstaller似乎正确地执行了一切,至少看起来没有任何错误编译。 As the blog post mentions there is a dist folder created and an application( hello.exe ) file created; 正如博客文章中提到的那样,创建了一个dist文件夹并创建了一个应用程序( hello.exe )文件; but when I click on it to run, a box will pop up critical error failed to run hello 但当我点击它运行时,一个框会弹出critical error failed to run hello

Any tips greatly appreciated... 任何提示非常感谢...

You are setting Flask app's debug=True which means that you want to run it in debug mode. 您正在设置Flask应用程序的debug=True ,这意味着您要在调试模式下运行它。 On the other hand, you are disabling the python' console in your output executable with -w flag. 另一方面,您使用-w标志禁用输出可执行文件中的python'控制台。 This is your error. 这是你的错误。 Either remove -w flag from your Pyinstaller build command or set debug=False in your Flask's app. 从Pyinstaller构建命令中删除-w标志或在Flask的应用程序中设置debug=False

I suggest you keep the console window because if you get any error in your Flask app you would see the error log in the console. 我建议您保留控制台窗口,因为如果Flask应用程序中出现任何错误,您将在控制台中看到错误日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM