3b1b/manim · error

Please use a valid color

Error message

Please use a valid color

What it means

While applying CLI/config arguments, update_camera_config parses the -c/--color background color with colour.Color. If parsing fails, manim logs 'Please use a valid color' plus the underlying colour-library error and exits with status 2 — it is a startup-time config failure, not a Python exception propagated to the caller.

Source

Thrown at manimlib/config.py:261

    window_config = config.window
    for key in "position", "size":
        if window_config.get(key):
            window_config[key] = literal_eval(window_config[key])
    if args.full_screen:
        window_config.full_screen = True


def update_camera_config(config: Dict, args: Namespace):
    camera_config = config.camera
    arg_resolution = get_resolution_from_args(args, config.resolution_options)
    camera_config.resolution = arg_resolution or literal_eval(camera_config.resolution)
    if args.fps:
        camera_config.fps = args.fps
    if args.color:
        try:
            camera_config.background_color = colour.Color(args.color)
        except Exception as err:
            log.error("Please use a valid color")
            log.error(err)
            sys.exit(2)
    if args.transparent:
        camera_config.background_opacity = 0.0


def update_file_writer_config(config: Dict, args: Namespace):
    file_writer_config = config.file_writer
    file_writer_config.update(
        write_to_movie=(not args.skip_animations and args.write_file),
        subdivide_output=args.subdivide,
        save_last_frame=(args.skip_animations and args.write_file),
        png_mode=("RGBA" if args.transparent else "RGB"),
        movie_file_extension=(get_file_ext(args)),
        output_directory=get_output_directory(args, config),
        file_name=args.file_name,
        open_file_upon_completion=args.open,
        show_file_location_upon_completion=args.finder,

View on GitHub (pinned to dee01804d4)

Solutions

  1. Use a 6-digit hex string: -c '#1a2b3c' or '#1A2B3C'
  2. Use a color name the colour library knows: -c DARK_BLUE, -c red, -c teal
  3. Note the CLI takes a string; if setting from Python, assign colour.Color(...) or manim's ManimColor-compatible values, not a tuple

Example fix

# before
manim -c slate_grey_bluish scene.py MyScene
# after
manim -c '#3C4043' scene.py MyScene
Defensive patterns

Strategy: validation

Validate before calling

import colour
color = "#3C4043"
try:
    colour.Color(color)
except ValueError:
    raise SystemExit(f"{color!r} is not a colour-library color; use hex like '#RRGGBB'")

Type guard

import colour
def is_valid_color(s: str) -> bool:
    try:
        colour.Color(s)
        return True
    except Exception:
        return False

Prevention

When it happens

Trigger: Running manim -c 'darkblue2x' file.py Scene, or any color string colour.Color cannot parse: bad hex like '#GGGGGG', named colors that don't exist in the colour module, strings with stray whitespace or quotes.

Common situations: Using web CSS color names (e.g. 'slategray') that the colour library doesn't define; typos in hex codes; assuming RGB tuples or 0xRRGGBB integers work as strings; scripts that pass a programmatically-built color string.

Related errors


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