Cannot initialize flask initdb (Flask Tutorial Step4) Cannot initialize flask initdb (Flask Tutorial Step4) database database

Cannot initialize flask initdb (Flask Tutorial Step4)


I think you should follow this:

  1. edit the configuration in the flaskr.py file or export an FLASKR_SETTINGS environment variable pointing to a configuration file.

  2. install the app from the root of the project directory

    pip install --editable .
  3. Instruct flask to use the right application

    export FLASK_APP=flaskr
  4. initialize the database with this command:

    flask initdb
  5. now you can run flaskr:

    flask run

Pay attention to install --editable correctly. I don't see the "." the first time.


the correct expression should be:

export FLASK_APP=flaskr.py

Note: no spaces around =.

Following screenshot show you outputs with different envvar FLASK_APP :

screenshot


Ran into the same issue, fixed it with

python3 -m flask initdb

I had to do everything for the tutorial with python -m flask <command>

I'm guessing its something to do with python3 instead of python2 but I'm new to python so not super sure.