I have a question about running one streamlit app.py in other streamlit app.py
Here is how I do
app1.py
import streamlit as st
st.write( 'This is app1')
app2.py
import streamlit as st
st.write( 'This is app2')
Now I want to add them to
run_app.py
import subprocess
import streamlit as st
if st.button('run app1'):
subprocess.run(["streamlit", "run", app1.py])
if st.button('run app2'):
subprocess.run(["streamlit", "run", app2.py])
Now I run run_app.py in command line ,
streamlit run /Users/run_app.py --server.port 8501
Here comes my problem, I want to deploy this kind of case on streamlit cloud from github
When i open the streamlit app, it open run_app.py and show the page
but when I click run app1, nothing happen
So is there any special setting when deploy the case on streamlit-cloud
(I have set the requirements)
Another approach if you rather want to create 2 separate apps and want to call each of them from within your main app, you could also use Stlite Sandbox from the streamlit-extras component.
ββ Hello.py
ββ pages
ο½ββ1_st_app1.py # st_app1 needs the files from folder app1
ο½ββ app1 # this is a folder
ο½ββ app1.py # This is a python file without streamlit
ο½ββ app1.json
ο½ββ app1.jpg
ο½ββ2_st_app2.py # st_app2 needs the files from fold app1
ο½ββ app2 # this is a folder
ο½ββ app2.py
ο½ββ app2.json
ο½ββ app2.jpg
ο½ββ3_st_app3.py
ββ requirements.txt
I try on local and streamlit cloud, they do not work,
st_app1.py need import app1.py from app1, but an error of import app1.py occurs
How are you doing your imports? Imports should be relative to the main file of your app.
1_st_app1.py as a script in pages would need to import from pages.app1.app1 for example and you may need to make sure you have an __init__.py file (can be empty) sitting in pages/app1.