Windows下Flask run报错'Could not locate flask application' 原因?
2018-08-09 20:53 菜鸟Alex 阅读(13667) 评论(0) 编辑 收藏 举报-
运行环境Windows系统, 命令行工具powershell
-
执行如下命令报错:
- 设置
set FLASK_APP = run.py
- 运行
flask run
- 设置
-
报错如下: Flask找不到上面设置的应用,或者说找不到运行脚本
run.py
而报出:Error: Could not locate flask application. You did not provide the FLASK_APP environment variable
-
具体原因不清楚,不过找到了解决方案,将下面命令替换
set FLASK_APP = run.py
成$env:FLASK_APP = "run.py"
参考自Stack Overflow: https://stackoverflow.com/questions/37826016/env-variables-not-set-while-running-minimal-flask-application
问题:
解决方案: