Navigate to child page directly not working

My directory as shown

  • pages/
    • test2.py
  • test.py

I startup the app by running streamlit run test.py

(assuming running on localhost:8501)

If I navigate directly to localhost:8501/test2, the webpage is stuck and doesn’t load. However, if I go to localhost:8501 and access the test2 page from the side bar, it works fine.

Content doesn’t matter, I cleared all content and tried running it on another server, but it still gives the same result.

streamlit version: 1.36.0

There was a bug on this for Windows users that was resolved in streamlit 1.37 – could you try upgrading and see if that is fixed?

Hi @blackary, thanks for the reply, it works now!

EDIT:
It is not working. When I rerun the page on save, I get this error.

I’ve checked that it’s at the start of my page. Here is my code from line 1:

## Default Streamlit
import streamlit as st
from stqdm import stqdm
import os
from utils import go_to_homepage, log_tokens, lpkg, find_file

logo_path = find_file("./", "icon.png")

st.set_page_config(
    page_title="My Title",
    page_icon=logo_path or None,
    # layout="wide",
    initial_sidebar_state="collapsed", 
)

if logo_path:
    st.logo(logo_path)

...

My best guess is that find_file is doing something with a streamlit command, or (probably more likely) utils.py has some streamlit command in it, so that when you import from it, some streamlit command is run.

You could test this by not importing from utils at all, and just running st.set_page_config immediately, and if the error goes away, you can see what streamlit command(s) are being run when you import from utils, or when you run find_file

I see, indeed my utils.py has a few streamlit utils that I created. Feels a bit hacky, but I declare find_file inside each page instead of importing from utils.py and it works.

Do you have any suggestions for that? I’m thinking splitting streamlit utils and non-streamlit utils into 2 different utils.py files?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.