This guide explains how to install Streamlit on both Linux and Windows machines and how to run a 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 venv source venv/bin/activateReplace
venvwith any name you prefer for your virtual environment. -
Install Streamlit using pip:
pip install streamlit
-
(Optional) Create and activate a virtual environment:
python -m venv venv .\venv\Scripts\activateReplace
venvwith any name you prefer. -
Install Streamlit using pip:
pip install streamlit
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install required package:
pip3 install plotly
-
Run the script (example):
python streamlit_1.py
-
Deactivate the virtual environment:
deactivate
-
(Optional) Remove the virtual environment files:
rm -rf venv
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install required packages:
pip3 install streamlit pip3 install plotly pip3 install statsmodels
-
Run the script (example):
python streamlit_2.py
-
Deactivate the virtual environment:
deactivate
-
(Optional) Remove the virtual environment files:
rm -rf venv
Note:
- Ensure you are in the correct directory before running these commands.
- Removing the
venvfolder will delete the virtual environment and all installed packages.
- 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!