Problem with Streamlit1.44

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

Hi @xiyan

  1. Try and run each of the individual py files in your app and see if they work independently
  2. If they don’t, then in each file there is a problem, check and see if all your variables are properly initialized and if they are passed into any function, the have an appropriate value.

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()
1 Like

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