using-streamlit-cli
Documents Streamlit CLI commands for running apps, managing configuration, and diagnostics. Use when starting Streamlit apps, configuring runtime op…
它会碰到什么
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
Using the Streamlit CLI
The Streamlit CLI is the primary tool for running Streamlit applications and managing configuration. This skill covers all essential commands and configuration options.
Running Streamlit apps
Basic syntax
streamlit run [<entrypoint>] [-- config options] [script args]
Entrypoint options
| Argument | Behavior |
|----------|----------|
| (none) | Looks for streamlit_app.py in current directory |
| Directory path | Runs streamlit_app.py within that directory |
| File path | Runs the specified file directly |
| URL | Runs a remote script (e.g., from GitHub) |
Examples
# Run default app in current directory
streamlit run
# Run a specific file
streamlit run app.py
# Run from a URL
streamlit run https://raw.githubusercontent.com/streamlit/demo-uber-nyc-pickups/master/streamlit_app.py
# Alternative: run as Python module (useful for IDE configuration)
python -m streamlit run app.py
Running with uv (recommended)
Use uv run to run Streamlit in a virtual environment with automatic dependency management:
# Run with uv (automatically uses/creates virtual environment)
uv run streamlit run app.py
# With configuration options
uv run streamlit run app.py --server.headless=true
# With script arguments
uv run streamlit run app.py -- arg1 arg2
Using uv run is the recommended approach because it:
- Automatically manages virtual environments
- Resolves and installs dependencies from
pyproject.toml - Ensures reproducible environments across machines
- Avoids manual activation/deactivation of virtual environments
Setting configuration with streamlit run
Configuration options follow the pattern --<section>.<option>=<value> and must come after the script name.
> Recommendation: For persistent configuration, use .streamlit/config.toml in your project directory instead of command-line flags. This keeps your run command simple and makes configuration easier to manage and share with your team.
Examples
streamlit run app.py --server.port=8080
streamlit run app.py --server.headless=true
streamlit run app.py --server.runOnSave=true
streamlit run app.py --server.address=0.0.0.0
streamlit run app.py --client.showErrorDetails=false
streamlit run app.py --theme.primaryColor=blue
Combining multiple options
streamlit run app.py \
--server.port=8080 \
--server.headless=true \
--theme.primaryColor=blue \
--client.showErrorDetails=false
Passing arguments to your script
Script arguments come after configuration options. Use sys.argv to access them:
streamlit run app.py -- arg1 arg2 "arg with spaces"
In your script:
import sys
# sys.argv[0] = script path
# sys.argv[1:] = your arguments
args = sys.argv[1:]
Other CLI commands
View configuration
# Show all current configuration settings
streamlit config show
Cache management
# Clear all cached data from disk
streamlit cache clear
Diagnostics and help
# Show installed version
streamlit version
# List all available commands
streamlit help
# Open documentation in browser
streamlit docs
Project scaffolding
# Create starter files for a new project
streamlit init
Demo app
# Launch the Streamlit demo application
streamlit hello
Configuration precedence
Configuration can be set in multiple places. Order of precedence (highest to lowest):
- Command-line flags (
--server.port=8080) - Environment variables (
STREAMLIT_SERVER_PORT=8080) - Local config (
.streamlit/config.tomlin project directory) - Global config (
~/.streamlit/config.toml)
References
- Run your app - Concepts and methods for running Streamlit apps
- config.toml - Complete configuration options reference
- CLI reference - Full CLI command documentation
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。
它属于哪个仓库
.agents/skills/developing-with-streamlit/skills/using-streamlit-cli/SKILL.md同一个仓库里的其他技能
- developing-with-streamlit
- building-streamlit-chat-ui
- building-streamlit-custom-components-v2
- building-streamlit-dashboards
- building-streamlit-multipage-apps
- choosing-streamlit-selection-widgets
- connecting-streamlit-to-snowflake
- creating-streamlit-themes
- displaying-streamlit-data
- improving-streamlit-design
- optimizing-streamlit-performance
- organizing-streamlit-code