Reputation: 341
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?
Upvotes: 22
Views: 89222
Reputation: 1
I had the same problem, my solution was to create a venv and then activate it
python -m venv venv
.\venv\Scripts\activate
Upvotes: 0
Reputation: 961
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.
Upvotes: 0
Reputation: 11
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
Upvotes: 0
Reputation: 29
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
.
Upvotes: 1
Reputation: 538
Maybe you are working in another directory where the Flask is not installed.
Just install Flask on the current directory:
pip install flask
Upvotes: 6
Reputation: 137
Make sure you've saved the application.py and the app variable exists.
then run python -m flask run
,
Upvotes: 4
Reputation: 77
uninstall flask using the following command
pip uninstall flask
close cmd and open cmd as Administrator now run
pip install flask
check:
flask --version
Upvotes: 4
Reputation: 3628
If you have Anaconda, use python -m flask run
from Anaconda Prompt when you are on the folder of the script app.py
.
Upvotes: 1
Reputation: 730
Try using:
python -m flask run
Also make sure you are in the same directory as application.py
Upvotes: 36
Reputation: 11
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'.
Upvotes: 1
Reputation: 724
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.
Upvotes: 2
Reputation: 21
install flask: pip install flask in the working directory where application.py file is located.
Upvotes: 0