OSError: This app has encountered an error. The original error message is redacted to prevent data leaks

When I run streamlit run, I can upload images without error and they are displayed as I wrote them,
But when I upload to streamlit sharing, I get the error below

OSError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).
Traceback:

File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 379, in _run_script
    exec(code, module.__dict__)
File "/app/face_api_streamlit/main.py", line 74, in <module>
    draw_text(result)
File "/app/face_api_streamlit/main.py", line 44, in draw_text
    text, font = get_draw_text(faceDictionary)
File "/app/face_api_streamlit/main.py", line 34, in get_draw_text
    font = ImageFont.truetype('Arial', font_size)
File "/home/appuser/venv/lib/python3.7/site-packages/PIL/ImageFont.py", line 855, in truetype
    return freetype(font)
File "/home/appuser/venv/lib/python3.7/site-packages/PIL/ImageFont.py", line 852, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/home/appuser/venv/lib/python3.7/site-packages/PIL/ImageFont.py", line 212, in __init__
    font, size, index, encoding, layout_engine=layout_engine

What I did for fixing.
I changed the codes like below and run it but not resolved yet…

font = ImageFont.truetype(font='/System/Library/Fonts/Arial', size=20, index=0, encoding='', layout_engine=None)
font_path = '/System/Library/Fonts/Arial'

font = ImageFont.truetype(font=font_path, size=20, index=0, encoding='', layout_engine=None)

Mac OS
Python 3.9.2
Streamlit 1.4.0

Hi @01mayo, welcome to the Streamlit community!

It’s important to note that you are using a Mac for local development, and the Streamlit Cloud image is based on Debian. So specifying an exact file directory isn’t going to work.

According to this snippet, it looks like fonts are installed at /usr/share/fonts, but I would suggest trying to find a programmatic way to set that in your app so that you don’t need to switch the reference based on where the app is running.

Best,
Randy