Session state attribute error

I have tried implementing session state as mentioned in streamlit counter example but i am getting the attribute error in my terminal

AttributeError: st.session_state has no attribute โ€œcountโ€. Did you forget to initialize it?

However my UI appears to be working fine.
My streamlit version is 0.84.1


import pandas as pd 
import streamlit as st 


st.title('Counter Example')
if 'count' not in st.session_state:
    st.session_state.count = 0

increment = st.button('Increment')
if increment:
    st.session_state.count += 1

st.write('Count = ', st.session_state.count)
1 Like

Hi @Hassan_waseem

Iโ€™ve tried your app locally and it worked fine. Has the issue been fixed and are you still experiencing the issue?

If the latter, please could you elaborate on the problem?

Thanks,
Charly

The user interface is working fine but on my spyder terminal it is still showing the attribute error.
Is it due to my streamlit version
current version 0.84.1

I see.

Have you tried upgrading to 0.85?

I will give it a try

1 Like

Great.

Please keep us posted :slight_smile: