How to Install Streamlit on CentOS 8

Updated on August 3, 2021
How to Install Streamlit on CentOS 8 header image


Streamlit is an open-source python library designed to create custom web applications for machine learning and data science. It is one of the fastest ways to design, build, and deploy data applications. This article explains how to run a Streamlit-based web application on a CentOS 8 Server.

1. Install Prerequisites

Update Python

The default CentOS repositories contain Python 3.6.8 only, so we will use Python source code to install the latest version of Python3.

  1. Install the required dependencies to compile the Python source code.

     # yum groupinstall 'development tools' -y && yum install wget openssl-devel bzip2-devel libffi-devel xz-devel -y
  2. Download the latest Python3 source code.

     # wget
  3. Extract the downloaded python source code.

     # tar xvf Python-3.9.6.tgz
  4. Compile the python source code.

     # cd Python-3.9.6 && ./configure --enable-optimizations
  5. Install Python 3.9.6.

     # make altinstall
  6. Set Python 3.9.6 as default version.

     # alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.9 1 && alternatives --set python3 /usr/local/bin/python3.9 && echo "2" | alternatives --config python
  7. Update pip.

     # /usr/local/bin/python3.9 -m pip install --upgrade pip
  8. Set pip from Python 3.9.6 as default pip.

     # alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.9 1 && alternatives --set pip /usr/local/bin/pip3.9
  9. Check the current version of Python and pip.

     # python -V && pip -V
  10. Change to root directory.

     # cd

2. Install Streamlit

Install Streamlit using Python pip.

# pip install streamlit

3. Run Streamlit on CentOS 8

Option 1: Use the Default Port

  1. By default, Streamlit runs on port 8501, so you need to allow port 8501 on the firewall.

     # firewall-cmd  --permanent --add-port 8501/tcp
  2. Reload firewall-cmd.

     # firewall-cmd --reload
  3. When you run Streamlit on a normal SSH Session, the Streamlit process will close once you exit the SSH Session. To run Streamlit when you leave the SSH session, use tmux, a terminal multiplexer. Using a terminal multiplexer will allow you to run the Streamlit process in the background. To create a tmux session, run:

     # tmux new -s StreamlitSession

    You can change StreamlitSession to any session name you prefer. Please see How to Install and Use Tmux for more information.

  4. Once you are on the Terminal Multiplexer, you can now run your main python script. Make sure that your python script is in the /root/ directory, then run:

     # streamlit run

    Change to your python script file name.

  5. When you run Streamlit for the first time, you will be prompted to enter your email address. If you want to receive Streamlit updates, kindly enter your email address, or you can just press Enter to skip it.

  6. To view your deployed web application, visit http://server_ipaddress:8501

Option 2: Run Streamlit on HTTP Port

  1. To deploy your web application on HTTP Port (80), allow http port (80) on the firewall first. Run:

     # firewall-cmd --permanent --add-service=http
  2. Reload firewall-cmd:

     # firewall-cmd --reload
  3. Run your python script with Streamlit:

     # streamlit run --server.port 80

    Change to your python script file name.

  4. To view your deployed web application, visit http://server_ipaddress


If you have encountered some issues or if you want to learn more, please visit the Streamlit documentation.