19

I needed to setup Flask for windows, so I ran the following commands:

set FLASK_APP=application.py
set FLASK_DEBUG=1
set DATABASE_URL='postgres.......' =>(the credential given by the Heroku account)
flask run

But when I hit enter on the flask run, I get an error that says -

flask is not recognized as an internal or external command, operable program or batch file

Why is this not working? I've been trying to work on it but I'm still having the same error message.

What could be the issue?

5
  • 2
    Flask is not installed in that environment. Try pip show flask, if you see nothing, it means you have not installed flask in the environment you are executing Commented Nov 2, 2019 at 20:40
  • 1
    Thanks for your comment, running the pip show flask command, nothing actually showed, meaning flask was not installed. i used pip install flask to install the flask, still pip show flask displays nothing. Please what's the command for installing flask? Commented Nov 2, 2019 at 21:55
  • Or do you know of any resource that could get me up and running with flask? Commented Nov 2, 2019 at 21:58
  • Thanks for your contribution, flask is installed now Commented Nov 2, 2019 at 22:33
  • @NsikanAdaowo, Glad you got it going but it is customary to show the solution when you resolve it yourself. You asked the community to help you but you didn't give anything back.
    – Dale
    Commented May 15, 2021 at 5:06

13 Answers 13

34

Try using:

python -m flask run 

Also make sure you are in the same directory as application.py

1
  • 1
    If you are using a virtual environment, more accurately, make sure you activated and are in the same virtual environment where you installed Flask. Commented May 13, 2022 at 14:11
6

Maybe you are working in another directory where the Flask is not installed.

Just install Flask on the current directory:

pip install flask
4

uninstall flask using the following command

pip uninstall flask

close cmd and open cmd as Administrator now run

pip install flask

check:

flask --version
0
3

Make sure you've saved the application.py and the app variable exists.

then run python -m flask run ,

2

I faced the same issue. Perhaps you missed the message you received while installing 'flask'. While running pip install flask I received

WARNING: The script flask.exe is installed in 'C:\Users\ankur.kulshrestha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Either set the path in your PATH env variable or use the complete path while running flask run.

1

I had this same issue and resolved it by running this in CMD, where the path is set to your Python scripts folder:

set PATH=C:\Users\YOUR_USER_NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts

The error is related to the "WARNING" that may be shown when running 'pip install flask'. You can also confirm whether you installed flask successfully by using 'pip show flask'.

1

If you have Anaconda, use python -m flask run from Anaconda Prompt when you are on the folder of the script app.py.

1

If you're using a windows computer then run:

flask --app {name_of_file}

Run after setting:

set FLASK_APP=main.py

In my case: flask --app main run.

0

install flask: pip install flask in the working directory where application.py file is located.

0

Include your python version python3 -m flask run

0

i tried

python -m flask 

my problem was migrating a database and i couldn't run flask, so i wrote (python -m) before my command

0

Verify you have selected the correct Python interpreter. I was also facing the same issue but after selecting the proper Python interpreter and activating the virtual environment it is working fine.

0

Try using the command python first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.