Before you get started, you’re going to need a few things:
If you haven’t already, take a few minutes to read through Main concepts to understand Streamlit’s data flow model.
Set up your virtual environment¶
Regardless of which package management tool you’re using, we recommend running the commands on this page in a virtual environment. This ensures that the dependencies pulled in for Streamlit don’t impact any other Python projects you’re working on.
Below are a few tools you can use for environment management:
pip install streamlit
Now run the hello world app to make sure everything is working:
Now that everything’s installed, let’s create a new Python script and import Streamlit.
Create a new Python file named
first_app.py, then open it with your IDE or text editor.
Next, import Streamlit.
import streamlit as st # To make things easier later, we're also importing numpy and pandas for # working with sample data. import numpy as np import pandas as pd
Run your app. A new tab will open in your default browser. It’ll be blank for now. That’s OK.
streamlit run first_app.py
Running a Streamlit app is no different than any other Python script. Whenever you need to view the app, you can use this command.
Did you know you can also pass a URL to streamlit run? This is great when combined with Github Gists. For example:
$ streamlit run https://raw.githubusercontent.com/streamlit/demo-uber-nyc-pickups/master/streamlit_app.py
You can kill the app at any time by typing Ctrl+c in the terminal.