Issue
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?
Solution
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,
- navigate to https://anaconda.org/search?q=flask
- select the appropriate result for your OS.
- 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
- 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.
Answered By - J'e
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.