I'm having trouble using my Streamlit app because of a problem with the streamlit-card package. This is the error message I'm seeing:
2023-12-04 11:07:31.911 ComponentRequestHandler: GET /home/esoftdev1/bulkApi-deshboard/bulkapi-deshboard-env/lib/python3.12/site-packages/streamlit_card/frontend/build/null read error
Traceback (most recent call last):
File "/home/esoftdev1/bulkApi-deshboard/bulkapi-deshboard-env/lib/python3.12/site-packages/streamlit/web/server/component_request_handler.py", line 55, in get
with open(abspath, "rb") as file:
^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/esoftdev1/bulkApi-deshboard/bulkapi-deshboard-env/lib/python3.12/site-packages/streamlit_card/frontend/build/null'
- Code I used
from streamlit_card import card
count_yesterday = run_query("SELECT COUNT(*) FROM tbl WHERE op_status = 9000 AND DATE(creation_datetime) = (CURRENT_DATE - INTERVAL '1 day');")
yesterday = count_yesterday[0][0]
print(yesterday) #464
res = card(
text="Yesterday's Count",
title=yesterday,
styles={
"card": {
"width": "300px",
"height": "300px",
"border-radius": "10px",
"background-color": "RGB(128, 61, 245)",
"box-shadow": "0 0 10px rgba(0,0,0,0.5)",
},
"text": {
"font-family": "Times New Roman",
},
},
)
- Environment: Python version: 3.12.0, Streamlit version: 1.29.0, streamlit-card version: 0.0.61
- Directory Structure:
/home/esoftdev1/bulkApi-deshboard/bulkapi-deshboard-env/lib/python3.12/site-packages/streamlit_card/frontend/build
I have uninstalled streamlit-card using the command python3.12 -m pip uninstall streamlit-card
, reinstalled streamlit-card using the command python3.12 -m pip install streamlit-card
and upgraded streamlit-card using the command python3.12 -m pip install streamlit-card --upgrade
. I have cleared the browser cache.
You need to set a default image on the card, for some reason, the package does not allow the image to be optional. So using a sample image would be the best way.
Sample implementation:
from streamlit_card import card
count_yesterday = run_query("SELECT COUNT(*) FROM tbl WHERE op_status = 9000 AND DATE(creation_datetime) = (CURRENT_DATE - INTERVAL '1 day');")
yesterday = count_yesterday[0][0]
print(yesterday) #464
res = card(
text="Yesterday's Count",
title=yesterday,
styles={
"card": {
"width": "300px",
"height": "300px",
"border-radius": "10px",
"background-color": "RGB(128, 61, 245)",
"box-shadow": "0 0 10px rgba(0,0,0,0.5)",
},
"text": {
"font-family": "Times New Roman",
},
},
image="https://upload.wikimedia.org/wikipedia/en/4/48/Blank.JPG"
)