How to call a CLI tool with os.system() by using ballback of a button

Call os.system() with st.button on_click callback

I would like to call a CLI tool with os.system() by clicking a button. But my initial code does not work - it hangs.

Steps to reproduce

Code snippet:

import streamlit as st
import os

def call_cli():

st.button("call cli",on_click=call_cli)

Hi @Bo_Qiang

You can run CLI via Popen from subprocess. Please see the repo:

And the video that shows how to implement this by running R in a Streamlit app:

Hope this helps!

Best regards,

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.