用途:Streamlit CLI 是运行 Streamlit 应用和管理配置的主要工具,本技能整理其常用命令与配置选项。
主要能力:运行应用(streamlit run)、查看配置(streamlit config show)、清理缓存(streamlit cache clear)、查看版本(streamlit version)、列出命令(streamlit help)、打开文档(streamlit docs)、初始化项目(streamlit init)、启动示例应用(streamlit hello)。
运行应用:基本语法为 streamlit run [<entrypoint>] [-- config options] [script args]。不写入口时查找当前目录的 streamlit_app.py;也可传目录路径、文件路径或远程 URL。可用 python -m streamlit run app.py 作为替代方式。推荐用 uv run streamlit run app.py 运行,便于自动管理虚拟环境与依赖。
配置:选项格式为 --<section>.<option>=<value>,须放在脚本名之后,例如 streamlit run app.py --server.port=8080、--server.headless=true。持久配置建议使用项目目录下的 .streamlit/config.toml。配置优先级从高到低为:命令行参数、环境变量、本地 config.toml、全局 config.toml。
脚本参数:脚本参数写在配置选项之后,如 streamlit run app.py -- arg1 arg2 "arg with spaces",脚本中通过 sys.argv 获取。
限制:资料仅说明命令与配置形式,未提供具体版本要求、平台范围或效果说明。