This guide explains how to install Streamlit on both Linux and Windows machines and how to run a basic Streamlit program.
Streamlit is an open-source Python library that makes it easy to create and share beautiful, custom web apps for machine learning and data science.
- Python 3.7 or above
- pip (Python package manager)
Tip: It is recommended to use a virtual environment to avoid dependency conflicts.
-
Update your system packages (optional):
sudo apt update
-
(Optional) Create and activate a virtual environment:
python3 -m venv streamlit-env source streamlit-env/bin/activate -
Install Streamlit using pip:
pip install streamlit
-
(Optional) Create and activate a virtual environment:
python -m venv streamlit-env .\streamlit-env\Scripts\activate
-
Install Streamlit using pip:
pip install streamlit
-
Create a Streamlit Python script
Example:
app.pyimport streamlit as st st.title('Hello, Streamlit!') st.write('Welcome to your first Streamlit app!')
-
Run the Streamlit app
On both Linux and Windows, use the following command in your terminal:
streamlit run app.py
-
Access the app
After running the command, Streamlit will provide a local URL (usually
http://localhost:8501) that you can open in your browser.
- If you encounter issues, ensure Python and pip are correctly installed.
- For permission errors, try using
pip install --user streamlit. - If you installed in a virtual environment, ensure it's activated before running commands.
Happy Streamlit-ing!
