Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installed Flask in a virtualenv yet "command not found"

Tags:

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$  
like image 330
Gabriel Avatar asked May 14 '15 00:05

Gabriel


People also ask

How do I install a flask in Python virtual environment?

First make sure you've installed Python 3 and are using it inside a virtual environment. Now, execute the workon command to see a list of virtual environments in your machine. This should list py3-flask in a line. to ensure that you are indeed inside a Python 3 environment.

How do I run a flask app from the command line?

To run the app outside of the VS Code debugger, use the following steps from a terminal: Set an environment variable for FLASK_APP . On Linux and macOS, use export set FLASK_APP=webapp ; on Windows use set FLASK_APP=webapp . Navigate into the hello_app folder, then launch the program using python -m flask run .

Why pip install flask is not working?

To check if you have actually installed flask, try this command: pip freeze then check if it is actually listed. Normal procedure to start a flask app would be: - create a virtual environment. Make sure you are using python 3. check by using this command.


1 Answers

Flask 0.10 has no flask command, it was added in 0.11. If pi.py has the smarts to run your app, such as if it's using Flask-Script, the command you're looking for is:

$ python pi.py 

You can install Flask-CLI to get the flask command in 0.10 if you can't upgrade to 0.11.

like image 180
dirn Avatar answered Sep 29 '22 20:09

dirn