Permission Error [error 13] with @cache_data for deployed streamlit app

Works locally but run into the permission error when deployed to streamlit cloud:

PermissionError: [Errno 13] Permission denied: ‘/home/adminuser/venv/lib/python3.9/site-packages/shap/cached_data’


File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/", line 552, in _run_script
    exec(code, module.__dict__)File "/mount/src/", line 325, in <module>
    X,y = load_shap_data()File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/", line 211, in wrapper
    return cached_func(*args, **kwargs)File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/", line 240, in __call__
    return self._get_or_create_cached_value(args, kwargs)File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/", line 266, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/", line 320, in _handle_cache_miss
    computed_value = self._info.func(*func_args, **func_kwargs)File "/mount/src/", line 307, in load_shap_data
    return "/home/adminuser/venv/lib/python3.9/site-packages/shap/", line 169, in adult
    cache(github_data_url + ""),File "/home/adminuser/venv/lib/python3.9/site-packages/shap/", line 321, in cache
    os.makedirs(data_dir, exist_ok=True)File "/usr/local/lib/python3.9/", line 225, in makedirs
    mkdir(name, mode)

Hi @huang1000,

Thank you for sharing your question with the community!

So it seems your code is trying to write to a directory (shap/cached_data) but it does not have the permission to do so on the Streamlit Community Cloud.

Also, please check out our guidelines on how to post an effective question here and update your post to help the community answer your question.