Flask init-db no such command

First, be sure to activate your virtual environment. If you are using a new terminal then run the command below:

export FLASK_APP="flaskr"
export FLASK_ENV=development

Run the flask app

flask run

After that run the DB command

flask init_db

You should see the Database Initialized message.


I found the problem.
When I launched flask --help, I saw there was an import error of a module. I just installed that module via pip, and it was okay.


In order to run init-db command, you first need to make sure you are outside the flaskr package (use pwd command if not sure) and at the same level as venv folder, then set the two below on the terminal:

$env:FLASK_APP = "flaskr"
$env:FLASK_ENV = "development"

Then run:

flask init-db

Output: Initialized the database.

You don't need to install any extra packages if you follow the tutorial and execute the commands as they say.

Tags:

Python

Flask