Skip to content

Instantly share code, notes, and snippets.

@Sven-Bo
Last active July 20, 2024 10:31
Show Gist options
  • Save Sven-Bo/31d98f80b5fed1d3f53cf98e5b61e7c9 to your computer and use it in GitHub Desktop.
Save Sven-Bo/31d98f80b5fed1d3f53cf98e5b61e7c9 to your computer and use it in GitHub Desktop.
import json
import requests # pip install requests
import streamlit as st # pip install streamlit
from streamlit_lottie import st_lottie # pip install streamlit-lottie
# GitHub: https://github.com/andfanilo/streamlit-lottie
# Lottie Files: https://lottiefiles.com/
def load_lottiefile(filepath: str):
with open(filepath, "r") as f:
return json.load(f)
def load_lottieurl(url: str):
r = requests.get(url)
if r.status_code != 200:
return None
return r.json()
lottie_coding = load_lottiefile("lottiefile.json") # replace link to local lottie file
lottie_hello = load_lottieurl("https://assets9.lottiefiles.com/packages/lf20_M9p23l.json")
st_lottie(
lottie_hello,
speed=1,
reverse=False,
loop=True,
quality="low", # medium ; high
renderer="svg", # canvas
height=None,
width=None,
key=None,
)
@RoskoMx
Copy link

RoskoMx commented Jan 26, 2024

image

Hi how are you. Excuse me, I have a question; I try to run this code from a repository on Github, calling it with streamlit, but I get this message and I don't know how I could solve it. Could you guide me?

@Sven-Bo
Copy link
Author

Sven-Bo commented Jan 26, 2024

Hi how are you. Excuse me, I have a question; I try to run this code from a repository on Github, calling it with streamlit, but I get this message and I don't know how I could solve it. Could you guide me?

As written in the comment and in the error message, you need to install the streamlit-lottie package: pip install streamlit-lottie

@RoskoMx
Copy link

RoskoMx commented Jan 26, 2024

image

Thank you very much for answering. I did it from the cmd of my operating system and I have also already restarted it. I'm very beginner at this, sorry.

@Sven-Bo
Copy link
Author

Sven-Bo commented Jan 26, 2024

I suggest creating a separate virtual environment and installing the required libraries there. This will ensure that you have a clean, isolated environment for running your Python code, which can help avoid conflicts with any other libraries that you have installed on your machine.
I cannot offer much Python debugging here in the comments, but I hope it gives you a starting point 😅 I hope you understand. Happy debugging!

@RoskoMx
Copy link

RoskoMx commented Jan 26, 2024

Thank you very much. Greetings from a mexican in France.

@yvesmango
Copy link

Thank you very much. Greetings from a mexican in France.

@RoskoMx i faced the similar issue as well - just redeploy the app and you should be good. i think the issue has to do with caching in package initialization when we first deploy an app

IMG_1582

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment