Func.clear() not working in 1.20


Once I updated from 1.19 to 1.20, function specific cache clearing stopped working. Clearing the entire cache works fine. It seems to be related to the path of where the cache is stored, since it gives me this error message:

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\USERNAME\\.streamlit\\cache'

Steps to reproduce

  1. Add caching to a function
def func(x):
    # do something
    return f"new value = {x}"
  1. Try to clear the funcions cache
x = st.slider('value', 0, 10, 1, 1)
y = func(x)
if st.button('press to clear cache'):


Expected behavior:

The cache of the function should clear, and the page should rerun

Actual behavior:

The previous error is raised

Debug info

  • Streamlit version: 1.20
  • Python version: 3.10.8
  • Using Conda? Yes
  • OS version: Windows 10
  • Browser version: Google Chrome (latest)

Additional information

  • When downgrading to Streamlit 1.19 the error is gone

Please let me know if I need to add more information! Thanks for the amazing work!


1 Like

Looks like a regression. As a workaround, create en empty folder in the specified path.

1 Like