Skip to content
Advertisement

flask –app hello run — Error: No such option: –app

TL;DR running flask --app from the command line results in Error: No such option: --app.

The current version of Anaconda (at the time of this question) includes Flask version 1.x. Here is the code from the Flask hello world tutorial at: palletsprojects.com quickstart

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"

and running it with: flask --app hello run results in the error,

 Error: No such option: --app

How can I run this with the “–app” option?

Advertisement

Answer

Display your flask version with flask --version. Using the defaults from the anaconda package manager condata update flask won’t update flask to 2.x. --app works in >=2.2.x. In my case, at the time of this post, conda search flask did not show anything past version 2.1.3. To get this version or the latest available,

  1. navigate to https://anaconda.org/search?q=flask
  2. select the appropriate result for your OS.
  3. Use one of the example provided and add your desired version to the end e.g. conda install -c conda-forge flask=2.2.2
  4. Run flask --app and you should get: Error: Option '--app' requires an argument.

Note: If you’re seeing an Exception: HTTPConnectionPool(…, make sure you are running these command from an anaconda terminal.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement