Skip to content

Installing in a virtual environment

Eric (Po-Tsung) Chiu edited this page Sep 5, 2024 · 6 revisions

On Windows

Streamlit's officially-supported environment manager on Windows is Anaconda Navigator.

Install Anaconda

Follow the steps at the Anaconda installation page.

Create a new environment with Streamlit

  1. Follow the steps in this section of the Anaconda "Getting Started" page

  2. Click the "▶" icon next to your new environment and then "Open terminal":

    "Open terminal" in Anaconda Navigator

  3. In the terminal that appears, type:

    pip install streamlit
  4. Test that the installation worked:

    streamlit hello

    Streamlit's Hello app should appear in a new tab in your web browser!

Use your new environment

  1. In Anaconda Navigator, open a terminal in your environment (see step 2 above).

  2. In the terminal that appears, use Streamlit as usual:

    streamlit run myfile.py

On Mac / Linux

Streamlit's officially-supported environment manager on Mac and Linux is pip. See instructions on how to install and use it below.

Install Pipenv

On a Mac, that's:

sudo easy_install pip

If you use Ubuntu and Python 3, that's:

sudo apt-get install python3-pip

For other Linux distributions, see this guide.

Create a new environment with Streamlit

  1. Go to the folder where your project will live:

    cd myproject
  2. Create a new Pipenv environment in that folder:

    python -m venv venv

    When you run the command above, a directory called venv will appear in myprojects/. This directory is where your Python environment and dependencies are installed.

  3. Activate your environment:

    source ./venv/bin/activate
  4. Install Streamlit in your environment:

    pip install streamlit
  5. Test that the installation worked:

    streamlit hello

    Streamlit's Hello app should appear in a new tab in your web browser!

Use your new environment

  1. Any time you want to use the new environment, you first need to go to your project folder (where the venv directory lives) and run:

    source ./venv/bin/activate
  2. Now you can use Python and Streamlit as usual:

    streamlit run myfile.py