blackary / st_pages

An experimental version of Streamlit Multi-Page Apps
MIT License
467 stars 77 forks source link

st_pages config in .streamlit/pages.toml doesn't work on Streamlit Cloud Environment #90

Closed hanpham32 closed 3 months ago

hanpham32 commented 9 months ago

I'm getting:

2024-01-09 05:21:27.524 Uncaught app exception

Traceback (most recent call last):

  File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script

    exec(code, module.__dict__)

  File "/mount/src/streamlit-deployment-test/main_page.py", line 2, in <module>

    from st_pages import show_pages_from_config, add_page_title

ModuleNotFoundError: No module named 'st_pages'

2024-01-09 05:21:27.652 503 GET /script-health-check (10.12.146.161) 130.20ms

I've added the package in my requirements.txt. Not sure why Streamlit Cloud isn't able to import st_pages

blackary commented 9 months ago

Can you share a link to your repo?

hanpham32 commented 9 months ago

Can you share a link to your repo?

Here is the repo at that point in history

.streamlit/pages.toml is hidden but here is the file:

# pages.toml

[[pages]]
path = "main_page.py"
name = "Home"
icon = "🏠"

[[pages]]
path = "pages/about.py"
name = "About"
icon = "🦦"

[[pages]]
path = "pages/page_2.py"
name = "Another page"
blackary commented 9 months ago

It appears that .streamlit/pages.toml is not hidden, does not exist in that repo at that point in time https://github.com/hanpham32/streamlit-deployment-test/tree/4a15b4d25ad732bc39d831608779cc42f2de5732 -- you'll need to make sure you actually upload that file for show_pages_from_config() to actually work. This is probably the case because you put .streamlit/ in your .gitignore, so git will by default ignore all files in your gitignore. You probably meant to add .streamlit/secrets.toml into your gitignore.

That doesn't explain the ModuleNotFoundError, but if you do end up switching back to st_pages, you'll need to make sure that file is included in the repo. I'm still confused why that was happening, sorry. You might check in the app logs to see if there was some issue installing the dependencies https://docs.streamlit.io/streamlit-community-cloud/manage-your-app#streamlit-community-cloud-logs

Side note: I noticed that in the current version of the repo, you added streamlit_extras to your packages.txt, but that won't work -- you want to add that to requirements.txt, as packages.txt is only for ubuntu packages, not for pip packages.

danilo-css commented 9 months ago

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.

hanpham32 commented 9 months ago

@danilo-css do you have the same ModuleNotFoundError problem?

Clovinlee commented 9 months ago

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.

Im experiencing the same problem, and this works for me as well