{"id":2895,"library":"colour","title":"Colour (Simple Color Manipulation)","description":"The `colour` library, version 0.1.5, provides simple utilities for converting and manipulating various color representations such as HSL, RGB, web (hex), and X11 named colors. It offers a `Color` object for object-oriented manipulation and also exposes single-purpose conversion functions. This library is older and has a slow release cadence, with its last release in 2017.","status":"maintenance","version":"0.1.5","language":"en","source_language":"en","source_url":"http://github.com/vaab/colour","tags":["color","colour","rgb","hsl","hex","conversion"],"install":[{"cmd":"pip install colour","lang":"bash","label":"Install stable release"}],"dependencies":[],"imports":[{"note":"The primary Color class is directly importable from the top-level package.","wrong":"import colour.Color","symbol":"Color","correct":"from colour import Color"}],"quickstart":{"code":"from colour import Color\n\n# Create a color object from a named color\nred_color = Color(\"red\")\nprint(f\"Red color: {red_color}\")\n\n# Convert to different formats\nprint(f\"Hex: {red_color.hex}\")\nprint(f\"RGB (0-1 tuple): {red_color.rgb}\")\nprint(f\"HSL (0-1 tuple): {red_color.hsl}\")\n\n# Create a color from RGB tuple\nblue_color = Color(rgb=(0, 0, 1))\nprint(f\"Blue color: {blue_color}\")\n\n# Generate a color gradient\nyellow = Color(\"yellow\")\ncolors = list(yellow.range_to(Color(\"purple\"), 5))\nprint(\"Gradient from yellow to purple:\")\nfor c in colors:\n    print(f\"- {c.hex}\")","lang":"python","description":"Demonstrates creating `Color` objects, converting between color spaces (hex, RGB, HSL), and generating a simple color gradient."},"warnings":[{"fix":"If you need color science functionality, use `colour-science` and uninstall this `colour` package. If you specifically need this simpler `colour` package, ensure `colour-science` is not installed, or import the necessary components explicitly using aliases (e.g., `import colour as simple_colour`).","message":"There is a significant naming conflict with the actively developed 'Colour Science for Python' library, which uses the package name `colour-science` but also commonly imports as `import colour`. Installing both `colour` (this package) and `colour-science` can lead to import ambiguity (e.g., `from colour import Color` might resolve to the wrong library's `Color` class or not find it, depending on installation order and Python path).","severity":"breaking","affected_versions":"All versions of `colour` and `colour-science`."},{"fix":"For active development, broader color science features, or support for modern Python versions, consider using the `colour-science` library (pypi package `colour-science`) or other maintained color libraries like `ColorAide`.","message":"This `colour` library (version 0.1.5) has not been updated since 2017 and is likely not actively maintained. It may lack support for newer Python versions or modern color spaces/standards. Its functionality is basic compared to more advanced and maintained color libraries.","severity":"deprecated","affected_versions":"0.1.5 and earlier"},{"fix":"Multiply the float values by 255 and cast to int (e.g., `r, g, b = [int(x * 255) for x in my_color.rgb]`) for 0-255 integer representations.","message":"The `Color` object's attributes like `rgb`, `hsl`, `hsv` return tuples of floats between 0 and 1. If you expect 0-255 integer values (common in some web/graphics contexts), you will need to scale them manually.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}