mac下flask安装过程无报错 命令运行flask,说command not found

看了好几个教程,安装过程没有太多坑,实际安装过程也很顺利,直到cmd运行。。。。command not found。。。。。
https://blog.csdn.net/testcs_...
主要参考:https://blog.csdn.net/CUFE_pa...
重新安装看起来也没啥问题:
ancysMac:ancysweb ancyhuang$ sudo pip install Flask
Password:
The directory '/Users/xx/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/xx/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: Flask in /Library/Python/2.7/site-packages (0.10.1)
Requirement already satisfied: Werkzeug>=0.7 in /Library/Python/2.7/site-packages (from Flask) (0.14.1)
Requirement already satisfied: Jinja2>=2.4 in /Library/Python/2.7/site-packages (from Flask) (2.10)
Requirement already satisfied: itsdangerous>=0.21 in /Library/Python/2.7/site-packages (from Flask) (1.1.0)
Requirement already satisfied: MarkupSafe>=0.23 in /Library/Python/2.7/site-packages (from Jinja2>=2.4->Flask) (1.1.0)

但是一运行:
ancysMac:ancysweb ancyhuang$ flask
-bash: flask: command not found

阅读 7.9k
3 个回答
新手上路,请多包涵

你先在command 里面用pip list 查看有没有 flask
clipboard.png
然后再写个测试demo.py

from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
    return "<h1>HelloWorld</h1>"
if __name__ == '__main__':
    app.run()

然后 python demo.py

图片描述

依然是这样,demo也能运行,浏览器中也能输出helloworld

新手上路,请多包涵

export PATH=$PATH:~/.local/bin/ # 若要永久生效则写入.bashrc 或者profile

再执行flask试试:

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题