Skip to content

Lottie Animation is not working in Windows #6

@tamalmaity-dev

Description

@tamalmaity-dev

Duplicate Check

  • I have searched the opened issues and there are no duplicates

Describe the bug

Problem with Lottie animation

I am encountering an Unknown control: lottie error when trying to use the Lottie control in my Flet application, even though the flet-lottie package is installed in my environment.

Environment:

  • Flet Version: >=0.27.6
  • flet-lottie Version: 0.1.0
  • Operating System: Windows
  • Python Version: 3.13.3
     ft.Lottie(
                     src="assets/earth.json", # Use the path directly
                     animate=True,
                      repeat=True,
                      width=200,
                      height=200,
                 )

but every time getting error : Unknown control: lottie

I also try different approach ..

import flet as ft
from flet_lottie import Lottie
import base64
import os

# Assume assets/satellite-earth-orbiting.json exists and is valid
LOTTIE_JSON_PATH = "assets/satellite-earth-orbiting.json"

def main(page: ft.Page):
    page.title = "Lottie Test"
    page.vertical_alignment = ft.MainAxisAlignment.CENTER

    json_base64 = None
    try:
        # Adjust path finding if necessary for the minimal example
        script_dir = os.path.dirname(os.path.abspath(__file__))
        absolute_path = os.path.normpath(os.path.join(script_dir, LOTTIE_JSON_PATH))
        with open(absolute_path, "r", encoding="utf-8") as f:
            json_data = f.read()
            json_base64 = base64.b64encode(json_data.encode('utf-8')).decode('utf-8')
    except Exception as e:
        print(f"Error loading Lottie JSON: {e}")
        # Add a text control showing the error if loading fails
        page.add(ft.Text(f"Error loading Lottie JSON: {e}"))
        return # Stop if loading failed

    if json_base64:
        lottie_control = Lottie(
            src_base64=json_base64,
            animate=True,
            repeat=True,
            width=200,
            height=200,
        )
        page.add(lottie_control)
    else:
         page.add(ft.Text("Lottie JSON could not be loaded."))


    page.update()

if __name__ == "__main__":
    ft.app(target=main, assets_dir="assets")

Still getting same ERROR: Unknown control: lottie

Code sample

Code
     ft.Lottie(
                     src="assets/earth.json", # Use the path directly
                     animate=True,
                      repeat=True,
                      width=200,
                      height=200,
                 )

To reproduce

  • Set up a Python environment with flet>=0.27.6 and flet-lottie==0.1.0 .
  • Create a simple Flet app using the Lottie control as shown above (using either src or src_base64 ).
  • Ensure a valid Lottie JSON file exists at the specified path.
  • Run the Flet application ( python main.py ).

Expected behavior

The Lottie animation should be displayed in the Flet window without errors.

Actual Behavior:

The application fails with the error message: Exception: Unknown control: lottie (or similar traceback indicating the control is not recognized).

Troubleshooting Steps Taken:

  • Confirmed flet-lottie is installed in the correct Python environment using pip list or uv pip list .
  • Tried reinstalling dependencies ( pip install -r requirements.txt --force-reinstall or uv sync --reinstall ).
  • Verified the Python interpreter used by the IDE/terminal matches the environment where packages are installed.
  • Restarted the IDE.
  • Tried loading the Lottie file using both src (relative path) and src_base64 .

Screenshots / Videos

Image

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 11

Flet version

0.27.6

Regression

No, it isn't

Suggestions

Please fix this issue

Logs

Logs
[Paste your logs here]

Additional details

No response

Activity

NiTRoeSE

NiTRoeSE commented on May 21, 2025

@NiTRoeSE

I have excact the same issue with same behavior.
Any suggestions or workaround known ?
Help or a fix would be great. Thanks in advanced!

PS:

Have this issue with flet 0.28.2 and 0.28.3 ( no other version tested)

SIRGPrice

SIRGPrice commented on May 26, 2025

@SIRGPrice

Try:

PATH = "assets/LottieAnimation.json"

with open(PATH, "r", encoding="utf-8") as json_file:
        json_data = json_file.read()
        
json_base64 = base64.b64encode(json_data.encode('utf-8')).decode('utf-8')

animacion = flet_lottie.Lottie(
    src_base64=json_base64,
    reverse=True,
    repeat=True,
    width=100,
    height=100
)

Use directly a constant that contains: "assets/LottieAnimation.json"

It works just perfect for me in the latest version.

transferred this issue fromflet-dev/fleton Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @NiTRoeSE@tamalmaity-dev@SIRGPrice

        Issue actions

          Lottie Animation is not working in Windows · Issue #6 · flet-dev/flet-lottie