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’

Traceback:

File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)File "/mount/src/test.py", line 325, in <module>
    X,y = load_shap_data()File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", line 211, in wrapper
    return cached_func(*args, **kwargs)File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/cache_utils.py", 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/cache_utils.py", 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/cache_utils.py", line 320, in _handle_cache_miss
    computed_value = self._info.func(*func_args, **func_kwargs)File "/mount/src/test.py", line 307, in load_shap_data
    return shap.datasets.adult()File "/home/adminuser/venv/lib/python3.9/site-packages/shap/datasets.py", line 169, in adult
    cache(github_data_url + "adult.data"),File "/home/adminuser/venv/lib/python3.9/site-packages/shap/datasets.py", line 321, in cache
    os.makedirs(data_dir, exist_ok=True)File "/usr/local/lib/python3.9/os.py", 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.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.