Aneesh Jose
Aneesh Jose

Reputation: 385

Flask app is not running when pyinstaller is used with --noconsole

I have created a basic hello world application in flask. Then I did pyinstaller --noconsole main.py. I have got main.exe file in /dist directory. 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)

Upvotes: 1

Views: 1348

Answers (1)

Meyer
Meyer

Reputation: 21

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

You can add the desired function to the top of your flask script

Upvotes: 2

Related Questions