Install & Compatibility
Where this runs
tested against v0.1.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.006s · 17.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.008s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Color
✓ from colour import Color
✗ import colour.Color
The primary Color class is directly importable from the top-level package.
Demonstrates creating `Color` objects, converting between color spaces (hex, RGB, HSL), and generating a simple color gradient.
from colour import Color
# Create a color object from a named color
red_color = Color("red")
print(f"Red color: {red_color}")
# Convert to different formats
print(f"Hex: {red_color.hex}")
print(f"RGB (0-1 tuple): {red_color.rgb}")
print(f"HSL (0-1 tuple): {red_color.hsl}")
# Create a color from RGB tuple
blue_color = Color(rgb=(0, 0, 1))
print(f"Blue color: {blue_color}")
# Generate a color gradient
yellow = Color("yellow")
colors = list(yellow.range_to(Color("purple"), 5))
print("Gradient from yellow to purple:")
for c in colors:
print(f"- {c.hex}")
Debug
Known issues
breakingThere 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).fixIf 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`).
affects: All versions of `colour` and `colour-science`.
deprecatedThis `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.fixFor 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`.
affects: 0.1.5 and earlier
gotchaThe `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.fixMultiply 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.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'colour'
The `colour` library has not been installed in the active Python environment or there's a typo in the import statement.
fixEnsure 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.
ImportError: cannot import name 'Color' from 'colour'
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'.
fixThe `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.
TypeError: 'module' object is not callable
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.
fixTo 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. AttributeError: type object 'Color' has no attribute 'random'
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.
fixThere 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()))`.
ValueError: invalid literal for int() with base 16: '...'
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).
fixEnsure 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')`. Upgrade
Version history
0.1.5latest on PyPI · released Nov 19, 2017
Audit
Dependencies
No dependency data recorded yet.