Installed virtualenv, activated it, pip installed flask, and yet, when i try to run a script or see if it recognised, i get command not found.
(project)gabriel@debian:~/project$ pip list
Flask (0.10.1)
itsdangerous (0.24)
Jinja2 (2.7.3)
MarkupSafe (0.23)
pip (1.5.6)
setuptools (5.5.1)
Werkzeug (0.10.4)
(project)gabriel@debian:~/project$ flask
-bash: flask: command not found
(project)gabriel@debian:~/project$ Flask
-bash: Flask: command not found
(project)gabriel@debian:~/project$ </3
Also tried:
(project)gabriel@debian:~/project$ python -m flask pi.py
/home/gabriel/project/bin/python: No module named flask.__main__; 'flask' is a package and cannot be directly executed
(project)gabriel@debian:~/project$
I'm using version 0.12.2 and got the same issue.Here is my solution:
python -m flask run FLASK_APP=/path/to/filename.py
I have used Flask 0.10.1 and to verify whether it's install you should activate the virtualenv and then type:
if it runs smoothly, you have it. To run the app you can either use
or use flask_script :
Hope this helps you
Flask 0.10 has no
flask
command, it was added in 0.11. Ifpi.py
has the smarts to run your app, such as if it's using Flask-Script, the command you're looking for is:You can install Flask-CLI to get the
flask
command in 0.10 if you can't upgrade to 0.11.I ran into this issue while running through the tutorial for version 0.12, so for people who find this thread hitting this issue with a later version, I was able to get the server running by using:
You need to upgrade flask Use the following command on the terminal in your virtual environment
Verify where you have installed flask:
Verify you are installing flask for your correct python version inside your virtual environment.
Find out your python version "inside your (venv)"
Installation of flask for python3
Installation of flask for python2
Installation of flask for default python (be careful if you are inside your (venv) or in your shell)
For people who run higher versions of Flask consider evaluating your environment as explained here.
For me the problem was installing flask for python2 when the binary of my (venv) ran python3.