How to Install Streamlit

Streamlit is an open-source Python library that allows you to create interactive, data-driven web applications quickly. It is widely used for data science, machine learning dashboards, and visualization projects.

Let us look at the installation of streamlit.

Need a Streamlit developer? Click here

Prerequisites

Before installing Streamlit, ensure you have the following:

Python: Streamlit requires Python 3.9 and above.

You can check your Python version by running:

				
					python --version

#or

python3 --version


				
			

pip: This is Python’s package manager, pip is needed to install Streamlit. 
Check if it’s installed.

				
					pip --version

				
			

If you do not have pip, install it with this command

				
					python -m ensurepip --upgrade

				
			

Creating a Virtual Environment

It’s a best practice to create a virtual environment before installing any Python packages.

It’s optional but recommended

Windows:

				
					python -m venv streamlit_env
streamlit_env\Scripts\activate

				
			

macOS/Linux:

				
					python3 -m venv streamlit_env
source streamlit_env/bin/activate

				
			

Once activated, your terminal will show the virtual environment name.

Installing Streamlit

With your virtual environment activated (if you used a virtual environment), install Streamlit using pip

				
					pip install streamlit

				
			

This command installs the latest version of Streamlit alongside all its dependencies.

Verifying the Installation

To ensure Streamlit is installed correctly, run:

				
					streamlit hello

				
			
  • This will launch Streamlit’s sample “Hello World” app in your default web browser.

  • If you see an interactive demo dashboard, the installation is successful.

Upgrading Streamlit

If you already have Streamlit installed but want the latest version, use

				
					pip install --upgrade streamlit

				
			

Running Your First Streamlit App

After installation, you can create your first app:

  1. Create a new Python file, e.g., app.py my_app.py, e.t.c

  2. Add the following code:

				
					import streamlit as st

st.title("Hello Streamlit!")
st.write("This is your first Streamlit app.")

				
			

Run the app:

				
					streamlit run app.py

				
			

Your browser will open http://localhost:8501, showing your interactive app

Summary

It’s easy and quick to set up Streamlit. By following this guide, you may set things up correctly with as few mistakes as possible. This lets you focus on making interactive web apps for your data science and machine learning projects. To keep projects separate and minimize dependency conflicts, it is highly suggested to use a virtual environment.

 

 

Learn more about Streamlit: Click Here

 

Watch Videos on Streamlit:

Leave a Reply

Your email address will not be published. Required fields are marked *