Streamlit is an open-source Python framework that allows you to create interactive web apps for data science and machine learning with minimal code. It works seamlessly with popular Python libraries like NumPy, Pandas, Matplotlib, scikit-learn, Keras, PyTorch and LaTeX.
Set Up a Virtual Environment
To install and run Streamlit safely, use a virtual environment. This keeps Streamlit and its dependencies separate from other Python projects. Open your terminal or command prompt and run:
python -m venv venv
This creates a virtual environment named 'venv'. You can change the name if you like.
Activate the Virtual Environment
Windows: venv\Scripts\activate
Mac/Linux: source venv/bin/activate
Install Streamlit
To install Streamlit, first make sure your virtual environment is active. Then, open your terminal and run:
pip install streamlit
-(3).jpg)
Verify Installation
To confirm that Streamlit is installed correctly, run:
streamlit hello
.png)
Check the Streamlit Version
1. Using Terminal: Open the terminal and write the command in your terminal:
streamlit --version
This command should tell you what version the installed streamlit package is.
.png)
2. Using pip: the following pip command gives all the detail of current versions of python modules which you installed in your system.
pip freeze

Update Streamlit Version
If you want to update your Streamlit version you can use any one of these commands.
python -m pip install --upgrade Streamlit
or
python -m pip install -U Streamlit
.png)
Basic Streamlit Functions
1. Adding a Title
import streamlit as st
st.title("Geeks for Geeks")
Output

2. Adding some text
import streamlit as st
st.title("Geeks for Geeks")
st.write("A Computer Science portal for Geeks")
Output
Creating a Simple Streamlit App
Create a Python file named myFirstStreamlitApp.py and add the following code:
import streamlit as st
st.title("Hello")
st.write("Hello World!")
Run the app:
streamlit run myFirstStreamlitApp.py
The app will open in your browser. Press Ctrl + C in the terminal to stop it. Your first Streamlit app will display “Hello” as the title and “Hello World!” as text.
Advantages of Streamlit
- It embraces python-scripting.
- Less code is needed to create amazing web-apps.
- No callbacks are needed since widgets are treated as variables.
- Data caching simplifies and speeds up computation pipelines