Skip to content
Advertisement

terminal error: flask run zsh: command not found: flask

I’m using a Mac , the python version is 2.7.10. and I installed flask

➜  Flask_blog python Python 2.7.10 (default, Oct  6 2017, 22:29:07) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
>>>

I try to follow the tutorial of flash on http://flask.pocoo.org/docs/1.0/

the commands:

➜  Flask_blog export FLASK_APP=flaskblog.py
➜  Flask_blog flask run                    
zsh: command not found: flask
➜  Flask_blog 

code in flaskblog.py:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

The error is command not found: flask

I also tried an other tutorial.

commands:

➜  Flask_blog cd /Users/jzd/Movies/flask/Second_video 
➜  Second_video python one.py                           
Sorry

code in one.py

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello World'

if __name__ == '__name__':
    app.run('0.0.0.0')
else:
    print("Sorry")

the condition __name__ == '__name__': did not pass.

I guess the python venv matters.

Really want to know how to fix it.

Advertisement

Answer

You could try python -m flask run instead.

Possible installation issues with flask not present, etc, are mentioned in this section of official Flask documentation.

Advertisement