Expose executables from path to streamlit/scope?

Hey @infvie, welcome to Streamlit!

To use pyomo inside a Streamlit app, you could do something like this:

import pyomo.environ as pyo
import streamlit as st

opt = pyo.SolverFactory('cbc')
opt.solve(model)

If you need your Streamlit app run a path executable directly, then you probably want to check out the Python subprocess module. For example:

import subprocess
import streamlit as st

result = subprocess.run(['pyomo', 'solve', 'my_model.py', '--solver="cbc"'])
st.write(result.stdout)  # Do something interesting with the result

For utilities that have both a Python library and a command line interface, like pyomo, it’s generally easier to use the Python API. Use the subprocess module only when you have to.