I’m using a Mac , the python version is 2.7.10. and I installed flask
JavaScript
x
6
1
➜ Flask_blog python Python 2.7.10 (default, Oct 6 2017, 22:29:07)
2
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
3
Type "help", "copyright", "credits" or "license" for more information.
4
>>> import flask
5
>>>
6
I try to follow the tutorial of flash on http://flask.pocoo.org/docs/1.0/
the commands:
JavaScript
1
5
1
➜ Flask_blog export FLASK_APP=flaskblog.py
2
➜ Flask_blog flask run
3
zsh: command not found: flask
4
➜ Flask_blog
5
code in flaskblog.py:
JavaScript
1
7
1
from flask import Flask
2
app = Flask(__name__)
3
4
@app.route("/")
5
def hello():
6
return "Hello World!"
7
The error is command not found: flask
I also tried an other tutorial.
commands:
JavaScript
1
4
1
➜ Flask_blog cd /Users/jzd/Movies/flask/Second_video
2
➜ Second_video python one.py
3
Sorry
4
code in one.py
JavaScript
1
13
13
1
from flask import Flask
2
3
app = Flask(__name__)
4
5
@app.route('/')
6
def index():
7
return 'Hello World'
8
9
if __name__ == '__name__':
10
app.run('0.0.0.0')
11
else:
12
print("Sorry")
13
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.