Streamlit
raw JSON → 1.55.0 verified Tue May 12 auth: no python install: verified quickstart: verified
Streamlit is an open-source Python library that empowers developers to build and share interactive web applications for data science and machine learning with minimal code. It allows transforming Python scripts into beautiful, interactive apps in minutes, supporting various data libraries and visualizations. The current stable version is 1.55.0, with a regular release cadence bringing new features and improvements.
pip install streamlit Common errors
error ModuleNotFoundError: No module named 'streamlit' ↓
cause The Streamlit library is not installed in the current Python environment or the environment is not active.
fix
Run
pip install streamlit in your terminal to install the library. error NameError: name 'st' is not defined ↓
cause The Streamlit library has not been imported or aliased as 'st' before attempting to use Streamlit functions.
fix
Add
import streamlit as st at the beginning of your Python script. error StreamlitAPIException: st.sidebar() doesn't exist. Did you mean st.sidebar.button() or st.sidebar.write()? ↓
cause Users mistakenly try to call `st.sidebar()` as a function to create a sidebar, but `st.sidebar` is an object used to access sidebar elements or a context manager.
fix
Use
with st.sidebar: as a context manager to place multiple elements in the sidebar, or call specific methods like st.sidebar.write() or st.sidebar.button(). error KeyError: 'my_key' not in st.session_state ↓
cause You are attempting to access a key in `st.session_state` that has not yet been initialized or set, leading to a KeyError.
fix
Initialize the key with a default value at the beginning of your script using
if 'my_key' not in st.session_state: st.session_state['my_key'] = default_value before accessing it. error streamlit run: command not found ↓
cause The `streamlit` command-line tool is not found in your system's PATH, typically because Streamlit was not installed or the Python environment where it's installed is not active.
fix
Ensure Streamlit is installed (
pip install streamlit) and that your Python environment (e.g., virtual environment) is activated before running streamlit run app.py. Warnings
gotcha Streamlit's reactive model reruns the entire script from top to bottom on every user interaction or code change. Be mindful of expensive operations and use `st.cache_data` or `st.cache_resource` to memoize functions and prevent unnecessary re-execution. Not using caching for heavy computations can lead to slow app performance. ↓
fix Decorate functions with `@st.cache_data` for data-related computations or `@st.cache_resource` for resources like ML models, especially for functions that perform heavy calculations or data loading.
breaking The `st.experimental_user` command has been removed. Access to user information might require alternative authentication methods or specific deployment configurations. ↓
fix Refactor authentication flows. For deployed apps, consider Streamlit Community Cloud's authentication features or custom solutions using `st.secrets` with external auth providers.
deprecated The `add_rows` command, used with `st.dataframe` or `st.table`, has been deprecated. While it may still function, its use is discouraged and it will eventually be removed. ↓
fix To update data in `st.dataframe` or `st.table`, re-assign the full, updated DataFrame to the component. Streamlit's diffing algorithm will efficiently update the display.
gotcha Widgets within `st.form` only submit their values and trigger a rerun when the `st.form_submit_button` is clicked. If you need immediate interaction, place widgets outside of a form. Also, `st.button` and `st.download_button` cannot be placed inside `st.form`. ↓
fix Design your app layout carefully, using `st.form` for batch inputs and direct `st.` calls for immediate interactivity. Do not put `st.button` or `st.download_button` inside a form. If a widget inside a form needs to trigger an immediate action, consider refactoring the logic or placing that specific widget outside the form.
deprecated `kwargs` support for `st.vega_lite_chart` is deprecated. Configurations should be passed via explicit parameters rather than keyword arguments. ↓
fix Update your `st.vega_lite_chart` calls to pass chart configurations using dedicated parameters as specified in the Streamlit API reference for `st.vega_lite_chart`.
gotcha Streamlit applications must be run using the `streamlit run <script_name>.py` command. Running a script directly with `python <script_name>.py` will not properly initialize the Streamlit environment, leading to issues like session state not functioning, widgets not displaying correctly, and the app not being viewable in a browser. The `missing ScriptRunContext` warnings are also a symptom of this. ↓
fix Always run your Streamlit application using `streamlit run <your_script_name>.py` from your terminal. Avoid running Streamlit scripts directly with `python` or integrating them into non-Streamlit execution contexts without proper embedding.
gotcha Streamlit applications must be run using the `streamlit run <script_name.py>` command. Running a script directly with `python <script_name.py>` will result in warnings about a missing `ScriptRunContext`, prevent session state from functioning correctly, and the app will not be viewable in a browser. ↓
fix Always execute Streamlit applications using `streamlit run <script_name.py>`.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) sdist - 1.27s 444.7M
3.10 alpine (musl) - - 1.17s 427.6M
3.10 slim (glibc) wheel 17.0s 0.54s 414M
3.10 slim (glibc) - - 0.43s 398M
3.11 alpine (musl) sdist - 1.77s 465.3M
3.11 alpine (musl) - - 1.83s 448.3M
3.11 slim (glibc) wheel 15.9s 0.92s 434M
3.11 slim (glibc) - - 0.68s 418M
3.12 alpine (musl) sdist - 1.81s 449.2M
3.12 alpine (musl) - - 1.78s 431.9M
3.12 slim (glibc) wheel 16.1s 1.12s 418M
3.12 slim (glibc) - - 0.93s 401M
3.13 alpine (musl) sdist - 1.68s 447.8M
3.13 alpine (musl) - - 1.69s 430.6M
3.13 slim (glibc) wheel 15.1s 1.04s 416M
3.13 slim (glibc) - - 1.64s 400M
3.9 alpine (musl) sdist - 1.19s 429.5M
3.9 alpine (musl) - - 1.11s 420.9M
3.9 slim (glibc) wheel 17.9s 0.52s 407M
3.9 slim (glibc) - - 0.47s 399M
Imports
- streamlit wrong
import streamlitcorrectimport streamlit as st
Quickstart verified last tested: 2026-04-24
import streamlit as st
st.title('My First Streamlit App')
name = st.text_input('What is your name?')
if name:
st.write(f'Hello, {name}!')
number = st.slider('Choose a number', 0, 100, 50)
st.write(f'The number is {number}')
# To run this app, save it as a .py file (e.g., app.py) and run `streamlit run app.py` in your terminal.