Installing Streamlit Beginner
Get Streamlit up and running in under a minute. This lesson covers installation, creating your first app, and using hot reload for rapid development.
Prerequisites
- Python 3.8 or higher
- pip package manager
- A code editor (VS Code recommended)
Step 1: Install Streamlit
Terminal
# Install Streamlit pip install streamlit # Verify installation streamlit --version # Run the built-in demo streamlit hello
Virtual Environment: It is recommended to use a virtual environment. Create one with
python -m venv .venv and activate it before installing Streamlit.
Step 2: Create Your First App
Python (app.py)
import streamlit as st st.title("My First Streamlit App") st.write("Hello, world! This is my first Streamlit application.") name = st.text_input("What's your name?") if name: st.write(f"Hello, {name}! Welcome to Streamlit.")
Step 3: Run Your App
Terminal
# Run the app streamlit run app.py # Output: # You can now view your Streamlit app in your browser. # Local URL: http://localhost:8501 # Network URL: http://192.168.1.100:8501
Hot Reload
Streamlit automatically detects changes to your source file and offers to re-run the app. You can configure this behavior:
- Always rerun: Click "Always rerun" in the top-right corner to auto-update on every save
- Manual rerun: Press
Rin the browser to rerun manually - CLI flag: Use
streamlit run app.py --server.runOnSave truefor auto-rerun
A More Complete Example
Python (app.py)
import streamlit as st import pandas as pd import numpy as np st.set_page_config(page_title="My App", page_icon="📊", layout="wide") st.title("Data Explorer") st.markdown("Upload a CSV file and explore your data interactively.") uploaded_file = st.file_uploader("Choose a CSV file", type="csv") if uploaded_file: df = pd.read_csv(uploaded_file) col1, col2, col3 = st.columns(3) col1.metric("Rows", df.shape[0]) col2.metric("Columns", df.shape[1]) col3.metric("Missing Values", df.isnull().sum().sum()) st.subheader("Data Preview") st.dataframe(df.head(20), use_container_width=True) st.subheader("Column Statistics") st.write(df.describe()) else: st.info("Upload a CSV file to get started.")
Streamlit Installed!
You have Streamlit running with hot reload. Next, explore the core features for building rich user interfaces.
Next: Core Features →
Lilly Tech Systems