Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

St-pages doesn't work properly on Streamlit Cloud environment #85

Open
patrykpalej opened this issue Dec 2, 2023 · 7 comments
Open

Comments

@patrykpalej
Copy link

I have an app with a very simple structure. I use st-pages there and everything works fine on my server. However when I send it to the Streamlit cloud, the pages names aren't rendered properly.

I know it may be related to environment, because the app works on my server, however maybe something can be changed to support Streamlit cloud as well?

Here is my code and deployed app:

https://github.com/patrykpalej/Real-Estate-Market-Analysis-dashboard/

https://real-estate-market-pl.streamlit.app/

Btw. I tried to setup my app with multiple combination in terms of setting PYTHONPATH, append sys.path etc. It looks like the behaviour was indeterministic, because sometimes it works, sometimes it doesn't and I cannot tell what's wrong and why.

@blackary
Copy link
Owner

blackary commented Dec 6, 2023

I'm not really sure why this is happening, but I think it has something to do with the fact that importing this file actually runs some code, because if I move the connection_string code inside of the fetch_and_preprocess it works for me. I would recommend doing that in general -- don't make importing a module actually run code.

I would also highly recommend you look into st.secrets for your credentials, rather than using os.environment https://docs.streamlit.io/streamlit-community-cloud/deploy-your-app/secrets-management, but that's probably unrelated.

@patrykpalej
Copy link
Author

You mean such a change? -> https://github.com/patrykpalej/Real-Estate-Market-Analysis-dashboard/blob/master/functions/data_loading.py

I rebooted the app in the cloud after push but pages names still aren't visible. Did you mean that it works for you locally or in the cloud? In my local environment it works as well. The only problem is in the streamlit cloud.

I will try st.secrets, havn't heard about it before.

@blackary
Copy link
Owner

blackary commented Dec 7, 2023

Sorry, I'm really not sure what's going wrong here -- I made a super simplified repo with two files and it works fine

import streamlit as st
from st_pages import Page, show_pages

st.set_page_config(layout="wide", page_title="Real Estate Market Analysis")


show_pages(
    [
        Page("streamlit_app.py", "Project description", "💻"),
        Page("pages/test.py", "Houses", "🏡"),
    ]
)

https://pages-test-avvfxcd95pfsnn9rwueqxg.streamlit.app/

I'm really not sure what's going wrong with your app :/

The good news is that you can use streamlit's native multipage app features as an alternative, you just have to add emojis to the filenames to add them to the sidebar https://docs.streamlit.io/library/get-started/multipage-apps/create-a-multipage-app

@patrykpalej
Copy link
Author

patrykpalej commented Dec 8, 2023

Yeah, I'll stick with traditional approach for handling pages. Maybe in future releases this issue will be overcome. Thank you for the feedback.

What's most interesting is that during the development process sometimes the pages were handled correctly, but then after new changes it corrupted again.

@Yelinz
Copy link

Yelinz commented Dec 19, 2023

@danilo-css
Copy link

@blackary I had the same problem and solved it adding "is_section=true" at the last page of my page list.

Seems that for it to work on Streamlit Cloud now at least 1 page has to have "is_section=true". If none have it doesn't work.

@patrykpalej
Copy link
Author

@blackary I had the same problem and solved it adding "is_section=true" at the last page of my page list.

Seems that for it to work on Streamlit Cloud now at least 1 page has to have "is_section=true". If none have it doesn't work.

I checked and it seems to work. Thank you!

mkls6 added a commit to TravelTransportTalk/TravelTalk that referenced this issue Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants