How to Install Streamlit on Ubuntu

Streamlit is the open-source Python library that helps web developers in creating new applications quickly. Not only a simple Python script is converted to the web application by using Streamlit but also widgets and dashboards can be added to the application. 

It also supports the integration of the applications with the other data libraries. Streamlit can be installed on Ubuntu using the command line method that is explained in this post with a step-by-step guide. 

How to Install Streamlit on Ubuntu Using the Pip

Follow the below-mentioned steps for installing Streamlit on Ubuntu using the Pip package manager. 

Step 1: Open the Terminal

First, launch the terminal by pressing the CTRL+ALT+T shortcut key:

How to Install Streamlit on Ubuntu 22.04 a

Step 2: Update the Packages

When the terminal is launched, ensure that all the packages are up to date with the execution of the command:

$ sudo apt update
How to Install Streamlit on Ubuntu 22.04 b

Step 3: Install Pip Package

The package of the Pip comes in the default repository of Ubuntu and can be installed with the command:

$ sudo apt install python3-pip -y
How to Install Streamlit on Ubuntu 22.04 c

Step 4: Verify the Pip’s Installation

To confirm the execution of the above command, display the installed version of the Pip:

$ pip --version
How to Install Streamlit on Ubuntu 22.04 d

Step 5: Install the Streamlit

Finally, install the package of the Streamlit using the pip package manager:

$ pip install streamlit
How to Install Streamlit on Ubuntu 22.04 e
How to Install Streamlit on Ubuntu 22.04 f

The Streamlit has been successfully installed on Ubuntu. 

How to Use the Streamlit on Ubuntu?

To explain the usage of Streamlit on Ubuntu, we will create a simple web application using it. To create it, first open the text file with the nano text editor and name it with the extension of py as shown:

$ nano myFirst_Application.py
How to Install Streamlit on Ubuntu 22.04 g

Now write the Python script for the application or copy-paste the below Python script:

import streamlit as st
#Name the Application's Title
st.title("First Application Using the Streamlit") 

#Add side bar options
option = st.sidebar.selectbox("Select an option:", ["Option 1", "Option 2", "Option 3"])  

# To display text
st.write(f"You selected: {option}")
How to Install Streamlit on Ubuntu 22.04 h

Now save the script by using the CTRL+S and then close the text editor. To run the application, run the script:

$ streamlit run myFirst_Application.py
How to Install Streamlit on Ubuntu 22.04 i

Open the mentioned URL in the browser:

Use the CTRL+C to terminate the application. 

How to Uninstall the Streamlit on Ubuntu Using the Pip?

Steamlit which is installed on Ubuntu using the Pip Python package manager, can be removed and uninstalled by running the command:

$ pip uninstall streamlit
How to Install Streamlit on Ubuntu 22.04 j

Conclusion

To install Streamlit on Ubuntu,  use the pip package manager by running the command “pip install streamlit” in the terminal. The installation method of the Streamlit on Ubuntu has been explained in this post with the step-by-step guidance. The basic usage of the Streamlit has also been explained with the help of the simple Python script.