New package st-pages: change page names and icons in sidebar without changing filenames

Ver nice! I will test it now

1 Like


I am getting this error in my google cloud run streamlit app since I am using st_pages in my app.
I am using python3.10-slim and below is my requirements.txt:
streamlit==1.16.0
st-pages
pandas
pandas-gbq
plotly
cloud-sql-python-connector[pg8000]
streamlit-authenticator

1 Like

Hi @ashish1, do you experience the same issue locally, or only when deployed to Google Cloud Run?

1 Like

yes @blackary , its happening with cloud run app only. st-pages is working fine with localhost and even with GCE docker deployment.

1 Like

I suspect thatā€™s related to this issue New package st-pages: change page names and icons in sidebar without changing filenames - #6 by rickspada, which I donā€™t have a fix for currently. This may be a limitation of this library for now, in that the very first time someone runs it it has this issue, which may mean itā€™s not suitable for a lambda-style environment. Iā€™ve added an issue for myself, and hopefully will come up with a fix for this at some point. Contributions welcome if anyone else has a suggested fix.

1 Like

Thanks @blackary for clarifying this, however for me even sidebar is not loading, I just get some loading message on the homepage and when I see cloud run logs out of range error is there.

1 Like

My suspicion is that the situation is this:

  • There is a limitation in the st_pages library that on the very first load of the site, it encounters that out of range error
  • For the typical use-case, where the app is essentially a long-running python script, all subsequent loads work fine, so itā€™s not a big deal
  • In the Google Cloud Run case, every visit to the app is a brand new run of the python script, so every single visit you will encounter that issue

I havenā€™t invested this use-case extensively, but thatā€™s my best guess. So, if I can figure out a fix to the general issue of the first-time-load error, it will also fix the Google Cloud Run case.

I know this doesnā€™t resolve the situation for you, but hopefully this explains better what I think is going on.

1 Like

ok. I think I got it now. Thanks for the detailed clarification @blackary. I will be looking forward to the future releases of the st_pages lib then. Thank you :slight_smile:

2 Likes

hello blackary
i am new in the community and i work with streamlit in my project.
for this exemple when i execute the script i donā€™t have shift between section and the pages inside

1 Like

Hi @diop95923, welcome to the forum!

Can you clarify ā€“ are you just showing an interesting use case of st_pages, or are you experiencing an issue?

1 Like

@ashish1 Can you try out the newly-released version 0.3.2 and see if you still experience this issue? I think I figured out and fixed what was causing the issue.

@blackary,
I think I found a fix for the first page not loading when using st-pages.
If you tack on a st.experimental_rerun() at the end of the script where you are calling all your pages it will reload and it has made it so the first page always loads (for me anyway!).
Let me know if this helps anyone :slight_smile:

Ooh, interesting. Does that hide the error message @tubbytim? Also, are you able to see if thatā€™s still required if youā€™re using version 0.3.2?

So this is how I have it set up:

When I run streamlit run mycoolapp.py now I never get a blank page, it loads directly into the top page (Which is exactly what I want it to do!). I am not getting any error either, on version 0.3.5 if that helps!

2 Likes

Also, loving the package! It really was a bugbear of mine having to include emojis and whatnot in the python file names!

2 Likes

Does this component support expandable sections? I donā€™t see anything regarding this so Iā€™m assuming it doesnā€™t but just wanna make sure

1 Like

@blackary, pip install st-pages is giving me error. ERROR: Could not find a version that satisfies the requirement st-pages (from versions: none)ERROR: No matching distribution found for st-pages

1 Like

Nope, sorry. If anyone is interested in adding expanding sections, that could be an interesting addition.

What OS and version of python are you using?

didnā€™t work in Python 3.7.13, but i upgraded and it worked. Thank you.

2 Likes