You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows下Flask启动报错,除flask run外还有其他启动方式吗?

解决Flask命令无法识别的问题

报错内容

flask : The term 'flask' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was 
included, verify that the path is correct and try again.  
At line:1 char:1  
+ flask run
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (flask:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

解决方法

  • 检查环境变量配置
    打开PyCharm终端输入pip show flask,查看Flask安装路径下的Scripts文件夹是否在系统PATH环境变量中。如果不在,手动添加该路径:右键"此电脑"→属性→高级系统设置→环境变量,在系统变量PATH中加入Scripts文件夹路径,重启终端重试。

  • 用Python模块方式启动
    直接执行python -m flask run,绕开环境变量限制,直接调用当前Python环境中的Flask模块启动服务。

  • 确认虚拟环境激活状态
    检查PyCharm终端左侧是否有虚拟环境前缀(如(venv)),未激活则手动执行激活命令:Windows系统输入venv\Scripts\activate,Mac/Linux输入source venv/bin/activate,激活后再执行flask run。

  • 验证Flask安装状态
    激活对应环境后输入pip list,确认列表中存在Flask。若没有,重新执行pip install flask完成安装。

内容的提问来源于stack exchange,提问作者Joshua Onyeabor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 21:12:01