AttributeError: '_thread._local' object has no attribute 'value'

I’m having an issue when I try to use a conditional statement to display text. My code is as follows:

st.header('Expected Winnings Based on Risk Profile')
option ="What level of risk would you like to adopt?",("High","Medium","Low"))
if option == "High":
    st.write("Your expected returns are: ",High_Risk_Winnings)
elif option == "Medium":
    st.write("Your expected returns are: ",Medium_Risk_Winnings)
    st.write("Your expected returns are: ",Low_Risk_Winnings)

High / Medium / Low _Risk_Winnings are all objects from my preceding code.

Once I’ve run the code, when I click on one of the radio buttons I get the following error message:
AttributeError: ‘_thread._local’ object has no attribute 'value’

Is anyone able to help me please?

Hey @Charly-Isabella, welcome to the Streamlit forums!

I tried running your code snippet and can’t reproduce the error. But after looking at the traceback you provided and doing a little more research, I think this is a Keras issue related to version 2.3.0 of Keras.

Is that the version you’re using? If so, can you try 2.2.5 or 2.3.1?

See this related Stack Overflow question for more info:

Otherwise, if this doesn’t fix your issue, would it be possible to share a more complete code snippet that includes the Keras part?



The previously proposed solution did not satisfied me as i did not want to downgrade Keras and TF. After searching online, I found this fix, which worked for me :

I’m using keras 2.3.1, tensorflow 2.0.0, python 3.6, linux Mint 19.2 Cinnamon.
My project is based on Waitress, so I can’t use “threaded=False”.

I found an UGLY workaround…
In the main “post manager” function I put this code…

import keras.backend.tensorflow_backend as tb
tb._SYMBOLIC_SCOPE.value = True

And this solved the problem for me…
I hope it will be useful to find a solution

By @ccasadei

I hope this can be a solution for others having the same problem as us.



Hi I set the

tb._SYMBOLIC_SCOPE.value = True

Then I am facing the issue of

ValueError: Cannot create an execution function which is comprised of elements from multiple graphs.

Hi @johnymephisto,

Welcome to the forum :wave:

Can you try the recommendation in this comment?

from tensorflow.keras ...

Instead of
from keras ...


Hi @Jonathan_Rhone, I already did this and it worked for me.

This made my day, thank you!
I needed:

from tensorflow.keras.applications.vgg16 import VGG16
instead of:
from keras.applications.vgg16 import VGG16
Although it was working in one folder right but not another.

1 Like

@Jonathan_Rhone Thank you for the recommendation. It works.

1 Like

I tried downgrading Keras-gpu (which is currently 2.3.1). However, for any version I try to downgrade to, I get an error. For example:

PackageNotFoundError: Packages missing in current channels:

  • keras-gpu 2.2.5*

We have searched for the packages in the following channels:

I have been stuck for many days trying to solve this. Please help.