Running Flask from IPython raises SystemExit
You're using Jupyter Notebook or IPython to run the development server. You've also enabled debug mode, which enables the reloader by default. The reloader tries to restart the process, which IPython can't handle.
Preferably, use the flask
command to run the development server.
export FLASK_APP=my_app.py
export FLASK_DEBUG=1
flask run
Or use the plain python
interpreter to run the application if you still want to use app.run
, which is no longer recommended.
python my_app.py
Or disable the reloader if you want to call app.run
from Jupyter.
app.run(debug=True, use_reloader=False)
In Visual Studio Code, to setup flask run
in the launcher (instead of launch python), use this configuration in .vscode/launch.json:
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": { "FLASK_APP": "my_app.py", "FLASK_ENV": "development" },
"args": ["run"],
"args_": ["run", "--no-debugger"],
"jinja": true
}