Agent skill

setting-up-streamlit-environment

Setting up Python environments for Streamlit apps. Use when creating a new project or managing dependencies. Covers uv for dependency management and running apps.

Stars 145
Forks 10

Install this agent skill to your Project

npx add-skill https://github.com/streamlit/agent-skills/tree/main/developing-with-streamlit/skills/setting-up-streamlit-environment

SKILL.md

Streamlit environment

Use whatever dependency management the project already has (pip, poetry, conda, etc.). If starting fresh and uv is available, it's a good default—fast, reliable, and creates isolated environments automatically.

If uv is not installed, ask the user before installing it.

CRITICAL: Always Use Latest Streamlit

Always specify streamlit>=1.53.0 (or latest) in dependencies. Many Streamlit features and patterns in these skills require recent versions. Older streamlit versions will cause errors with:

  • Material icons (:material/icon_name:)
  • st.pills(), st.segmented_control()
  • Modern caching decorators
  • Navigation APIs

When setting up a new project or fixing an existing one, always check and update the streamlit version.

Using uv

If uv is available, here's how to set up a Streamlit project.

Quick start (venv only)

For simple apps, just create a virtual environment:

bash
uv venv
source .venv/bin/activate  # or .venv\Scripts\activate on Windows
uv pip install streamlit

Run with:

bash
streamlit run streamlit_app.py

Full project setup

For larger projects or when you need reproducible builds:

bash
uv init my-streamlit-app
cd my-streamlit-app
uv add streamlit

This creates:

  • pyproject.toml with dependencies
  • uv.lock for reproducible builds
  • .venv/ virtual environment

Run with:

bash
uv run streamlit run streamlit_app.py

With options

Avoid setting options unless you have a specific reason:

bash
streamlit run streamlit_app.py --server.headless true  # Only for automated/CI environments

Add dependencies

bash
# With venv approach
uv pip install plotly snowflake-connector-python

# With full project (uv init)
uv add plotly snowflake-connector-python

Project structure

Keep it simple. For most apps:

my-streamlit-app/
├── .venv/
└── streamlit_app.py

Only add more when needed:

  • app_pages/ → Only for multi-page apps
  • .streamlit/config.toml → Only if customizing theme or settings
  • .streamlit/secrets.toml → Only if using secrets (add to .gitignore)
  • pyproject.toml → Only if using uv init for reproducible builds

Convention

Name your main file streamlit_app.py for consistency. This is what Streamlit expects by default.

What goes in the main module:

  • When using navigation: it's a router that defines pages and runs them
  • When there's no navigation: it's the home page with your main content

pyproject.toml Example

toml
[project]
name = "my-streamlit-app"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
    "streamlit>=1.53.0",
    "plotly>=5.0.0",
    "snowflake-connector-python>=3.0.0",
]

[tool.uv]
dev-dependencies = [
    "pytest>=8.0.0",
]

References

Expand your agent's capabilities with these related and highly-rated skills.

streamlit/agent-skills

template-skill

Replace with description of the skill and when to use it.

145 10
Explore
streamlit/agent-skills

developing-with-streamlit

**[REQUIRED]** Use for ALL Streamlit tasks: creating, editing, debugging, beautifying, styling, theming, optimizing, or deploying Streamlit applications. Also required for building custom components (inline or packaged), using st.components.v2, or any HTML/JS/CSS component work. Triggers: streamlit, st., dashboard, app.py, beautify, style, CSS, color, background, theme, button, widget styling, custom component, st.components, packaged component, pyproject.toml, asset_dir, CCv2, HTML/JS component.

145 10
Explore
streamlit/agent-skills

organizing-streamlit-code

Organizing Streamlit code for maintainability. Use when structuring apps with separate modules and utilities. Covers separation of concerns, keeping UI code clean, and import patterns.

145 10
Explore
streamlit/agent-skills

building-streamlit-chat-ui

Building chat interfaces in Streamlit. Use when creating conversational UIs, chatbots, or AI assistants. Covers st.chat_message, st.chat_input, message history, and streaming responses.

145 10
Explore
streamlit/agent-skills

building-streamlit-multipage-apps

Building multi-page Streamlit apps. Use when creating apps with multiple pages, setting up navigation, or managing state across pages.

145 10
Explore
streamlit/agent-skills

displaying-streamlit-data

Displaying charts, dataframes, and metrics in Streamlit. Use when visualizing data, configuring dataframe columns, or adding sparklines to metrics. Covers native charts, Altair, and column configuration.

145 10
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results