If you’re creating a debugging post, please include the following info:
Hi trying to run a small variation of the code here: https://docs.streamlit.io/develop/concepts/multipage-apps/page-and-navigation
I am getting the AttributeError. Not sure where I am going wrong.
- Are you running your app locally or is it deployed? Local
- If your app is deployed: No
- Share the link to your app’s public GitHub repository (including a requirements file).
- Share the full text of the error message (not a screenshot).:
AttributeError: 'function' object has no attribute '_default'
Traceback:
File "/Users/xxxxx/opt/anaconda3/envs/llm-venv-1/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 589, in _run_script
exec(code, module.__dict__)
File "/Users/xxxxx/Documents/GitHub/Agents/src/Agent_Home.py", line 25, in <module>
pg = st.navigation(
File "/Users/xxxxx/opt/anaconda3/envs/llm-venv-1/lib/python3.10/site-packages/streamlit/runtime/metrics_util.py", line 408, in wrapped_func
result = non_optional_func(*args, **kwargs)
File "/Users/xxxxx/opt/anaconda3/envs/llm-venv-1/lib/python3.10/site-packages/streamlit/commands/navigation.py", line 178, in navigation
if page._default:```
6. Share the Streamlit and Python versions.
Error:
Code:
import streamlit as st
st.set_page_config(page_title=“Home”, layout=“wide”)
if “logged_in” not in st.session_state:
st.session_state.logged_in = False
def login():
if st.button(“Log in”):
st.session_state.logged_in = True
st.rerun()
def logout():
if st.button(“Log out”):
st.session_state.logged_in = False
st.rerun()
login_page = st.Page(login, title=“Log in”, icon=“:material/login:”)
logout_page = st.Page(logout, title=“Log out”, icon=“:material/logout:”)
new_chat = st.Page(“pages/agent_chat.py”, title=“New Agent Chat”, icon=“:material/dashboard:”, default=True)
saved_chat = st.Page(“pages/saved_chat.py”, title=“Saved Agent Chat”, icon=“:material/bug_report:”)
if st.session_state.logged_in:
pg = st.navigation(
{
“Conversations”: [new_chat, saved_chat],
“Session”: [logout],
}
)
else:
pg = st.navigation([login_page])
pg.run()```
Streamlit Version: 1.36.0
Python: 3.9.17