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.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking βAccept allβ, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.