{"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":"python","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,"search_vec":"'0.1.5':9 '2017':63 'also':41 'cadenc':57 'color':3,18,29,33,64 'colour':1,6,65 'convers':46,69 'convert':14 'expos':42 'function':47 'hex':25,68 'hsl':22,67 'last':60 'librari':7,49 'manipul':4,16,39 'name':28 'object':34,37 'object-ori':36 'offer':31 'older':51 'orient':38 'provid':10 'purpos':45 'releas':56,61 'represent':19 'rgb':23,66 'simpl':2,11 'singl':44 'single-purpos':43 'slow':55 'util':12 'various':17 'version':8 'web':24 'x11':27","created_at":"2026-04-11T09:12:13.384536+00:00","updated_at":"2026-04-16T03:11:27.188013+00:00","problems":[{"fix":"Ensure the library is installed using pip: `pip install colour`. If using multiple Python environments, ensure it's installed in and imported from the correct one.","cause":"The `colour` library has not been installed in the active Python environment or there's a typo in the import statement.","error":"ModuleNotFoundError: No module named 'colour'"},{"fix":"The `Color` class is typically imported directly as `from colour import Color` in the `colour` library. If this still fails, check for a conflicting 'color' package and ensure only `colour` is installed, or try restarting your environment.","cause":"This usually happens when attempting to import the `Color` class directly from the top-level `colour` package, but `Color` is nested or not directly exposed in that manner, or there's a conflict with another installed module named 'color'.","error":"ImportError: cannot import name 'Color' from 'colour'"},{"fix":"To create a color object, instantiate the `Color` class: `from colour import Color; my_color = Color('red')`. Do not attempt to call the `colour` module directly.","cause":"This error occurs when trying to call the `colour` module itself as if it were a function or class constructor (e.g., `colour()`) instead of accessing a specific class or function within it, such as `colour.Color()` to create a color object.","error":"TypeError: 'module' object is not callable"},{"fix":"There is no built-in `Color.random()` method. To generate random colors, you would typically generate random RGB or HSL values and then create a `Color` object from those, e.g., using Python's `random` module: `import random; from colour import Color; c = Color(rgb=(random.random(), random.random(), random.random()))`.","cause":"Users attempting to generate a random color might search for a `random` method on the `Color` class, but the `colour` library (v0.1.5) does not provide such a method directly on the `Color` class for random color generation.","error":"AttributeError: type object 'Color' has no attribute 'random'"},{"fix":"Ensure that the hexadecimal string provided to `Color()` or conversion functions is a valid 3-digit or 6-digit hex code, optionally prefixed with '#', and contains only hexadecimal characters (0-9, a-f, A-F). For example: `Color('#FF0033')` or `Color('f00')`.","cause":"This error arises when attempting to convert an invalid hexadecimal string to an integer, typically within the `colour` library's functions that parse hex color codes. This could be due to malformed hex strings (e.g., containing non-hex characters, incorrect length, or leading/trailing characters).","error":"ValueError: invalid literal for int() with base 16: '...'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.5","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"http://github.com/vaab/colour","docs":null,"changelog":null,"pypi":"https://pypi.org/project/colour/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}