Running bash commands within Streamit - Is it possible?

Hi guys,

I’d like to integrate libraries like Ludwig in Streamlit.

Such library would require running bash commands in Streamit, like you would do in Colab. In Colab, you’d add an exclamation mark before the bash command to enable it - See screenshot below:

Would that be possible?


I mostly use Python subprocess for this, then you can capture output/error streamls and display them back in Streamlit :slight_smile:

(the following I don’t remember exactly if it works, just extracted it from one of my projects)

import streamlit as st
import subprocess

def run_command(args):
    """Run command, transfer stdout/stderr back into Streamlit and manage error""""Running '{' '.join(args)}'")
    result =, capture_output=True, text=True)
    except subprocess.CalledProcessError as e:
        raise e


1 Like

Thanks Fanilo! :pray:

In Ludwig’s case, it seems that both Bash script and Yaml file need to be considered:

I’ll give it a whirl :slight_smile:

Hi @andfanilo

I finally went with pure Python as there’s a Programmatic API! :slight_smile:

Thanks for the suggestion anyway, I’m sure subprocess will come very handy in the near future. :raised_hands:

Have a great weekend!