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

执行pip install -r requirements.txt报无效依赖'import streamlit as st'原因问询

报错根因

ERROR: Invalid requirement: 'import streamlit as st' (from line 1 of requirements.txt)

  • 你的requirements.txt第一行实际写入的是Python导入代码import streamlit as st,和你预期填写的streamlit不符,存在内容写错的问题。
  • requirements.txt是pip专用的依赖声明文件,语法要求每行仅填写依赖包名+可选版本约束,不支持任何Python代码语法,导入语句属于无效的依赖声明,pip无法解析因此抛出上述错误。
修复方案
  • 打开requirements.txt文件,清空所有非依赖声明的内容,仅保留需要安装的包信息,正确示例如下:
# 仅写包名即可,需要固定版本可加版本号,比如 streamlit==1.32.2
streamlit
  • 重新执行安装命令:pip install -r requirements.txt即可完成依赖安装。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.28 18:30:04