3b1b/manim · error · TypeError

Object {anim} cannot be converted to an animation

Error message

Object {anim} cannot be converted to an animation

What it means

prepare_animation normalizes arguments to scene.play(): it converts _AnimationBuilder objects (produced by mob.animate...) into real Animation instances and passes Animation instances through. Any other object raises TypeError with the object's repr, because the renderer has no way to animate it.

Source

Thrown at manimlib/animation/animation.py:244

    def get_rate_func(self) -> Callable[[float], float]:
        return self.rate_func

    def set_name(self, name: str):
        self.name = name
        return self

    def is_remover(self) -> bool:
        return self.remover


def prepare_animation(anim: Animation | _AnimationBuilder):
    if isinstance(anim, _AnimationBuilder):
        return anim.build()

    if isinstance(anim, Animation):
        return anim

    raise TypeError(f"Object {anim} cannot be converted to an animation")

View on GitHub (pinned to dee01804d4)

Solutions

  1. Wrap the mobject in an animation: self.play(FadeOut(circle)), self.play(Write(text))
  2. Use the .animate builder: self.play(circle.animate.shift(RIGHT))
  3. If you want to add without animating, call self.add(mobject) instead of self.play(mobject)

Example fix

# before
self.play(circle)
# after
self.play(Create(circle))
Defensive patterns

Strategy: type-guard

Validate before calling

from manimlib.animation.animation import Animation, prepare_animation
anims = [prepare_animation(a) for a in my_list]  # raises TypeError early with full list context
self.play(*anims)

Type guard

from manimlib.animation.animation import Animation
from manimlib.animation.animation import _AnimationBuilder
def is_animatable(x) -> bool:
    return isinstance(x, (Animation, _AnimationBuilder))

Prevention

When it happens

Trigger: self.play(circle) (a bare Mobject); self.play('fade') (a string); self.play(some_decorator_result); passing an _AnimationBuilder that was already built earlier (an Animation is fine, but e.g. a tuple of builders unpacked wrongly is not).

Common situations: Forgetting the animation class: play(FadeOut(mob)) not play(mob); expecting play() to implicitly add mobjects like play(ShowCreation) misremembered; passing the result of a helper that returns None.

Related errors


AI-assisted analysis of 3b1b/manim@dee01804d4 (2026-08-14). Data as JSON: /api/errors/00764dda13533c8a. Report an issue: GitHub.