When I updated Streamlit from version 1.42.2 to 1.44, I found any page stopped working and wouldn’t display anything
I’m not sure if it’s related to the changes below
Then, my code and directory structure looks like this
When I updated Streamlit from version 1.42.2 to 1.44, I found any page stopped working and wouldn’t display anything
Hi @xiyan
Cheers
Try this : in each of the pages/file.py
if name==“main”:
function_name()
Hello everyone!
I had this problem with my structure as well, after a few changes i went back online,
as of 1.44.0 if your pages structure was initialized like this
main.py
import streamlit as st
def main()
st.title("Main")
# User loggin
.
.
.
if __name__ == "__main__":
print(__name__)
main()
page_1.py
import streamlit as st
def page()
st.title("Page1")
if __name__ == "__page__":
print(__name__)
page()
page_2.py
import streamlit as st
def page()
st.title("Page2")
if __name__ == "__page__":
print(__name__)
page()
you will be not initialising the pages since now for each independet page file, __name__
will return __main__
instead of __page__
, therefor not initialising the page. What i did on every page file, replaced all __page__
with __main__
:
main.py
import streamlit as st
def main()
st.title("Main")
# User loggin
.
.
.
if __name__ == "__main__":
print(__name__)
main()
page_1.py
import streamlit as st
def page()
st.title("Page1")
if __name__ == "__main__":
print(__name__)
page()
page_2.py
import streamlit as st
def page()
st.title("Page2")
if __name__ == "__main__":
print(__name__)
page()
When I was using Stremalit1.43 and earlier versions, I always used
if __name__ == __page__:
Thank you very much for your suggestion, it indeed solved the problem I encountered
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.
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.
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.
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.