Registry / data / colour-science

colour-science

JSON →
library0.4.7pypypi✓ verified 86d ago

Colour Science is a comprehensive open-source Python package providing a collection of algorithms and datasets for colour science applications, including colourspace conversions, colour appearance models, and spectral computations. It's currently at version 0.4.7 and maintains an active development cycle with frequent alpha milestones and releases, often introducing new features and compatibility updates.

pip install colour-science
INSTALL
IMPORT
SIG · COLOUR-SCIENCE
C
colour-science
datapythonv0.4.7
Install
6.7s avg
Import
4717ms
Disk
218MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.6 · 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
musl
py 3.103.940 runs
installs and imports cleanly · install 0.0s · import 4.534s · 273.1MB
glibc
py 3.103.940 runs
installs and imports cleanly · install 6.7s · import 4.900s · 265MB
218MB installed
● package 218MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

colour
import colour
import colour_science
The PyPI package is `colour-science`, but the importable module is `colour`.
RGB_to_XYZ
import colour colour.RGB_to_XYZ(...)
Most functionalities are directly accessible via the top-level `colour` module or its submodules (e.g., `colour.models`, `colour.spaces`).

This quickstart demonstrates a basic colourspace conversion from sRGB to XYZ and then to CIE Lab using the `colour` library. It showcases how to import the library and use its primary conversion functions with NumPy arrays.

import colour import numpy as np # Define an sRGB colour in the range [0, 1] srgb_colour = np.array([0.4, 0.6, 0.8]) # Convert sRGB to XYZ D65 x_y_z_colour = colour.sRGB_to_XYZ(srgb_colour) # Convert XYZ D65 to Lab D65 lab_colour = colour.XYZ_to_Lab(x_y_z_colour) print(f"sRGB Colour: {srgb_colour}") print(f"XYZ D65 Colour: {x_y_z_colour}") print(f"Lab D65 Colour: {lab_colour}")
Debug
Known issues
breakingPython version support has evolved. As of v0.4.7, the library requires Python >=3.11 and <3.15. Older Python versions (e.g., 3.5, 3.10) are no longer supported.
fix
Ensure your Python environment is >=3.11 and <3.15. Upgrade Python if necessary, or use a compatible older version of 'colour-science' if specific Python versions are required.
affects: >=0.4.7
gotchaSeveral key dependencies like `scipy` and `imageio` became optional in v0.4.7. If your code relies on functionalities provided by these packages, you must explicitly install them, potentially using `pip install "colour-science[all]"` or `pip install colour-science[scipy,imageio]`.
fix
For existing projects, verify all required optional dependencies are explicitly listed in your project's requirements or installed via `pip install "colour-science[all]"`.
affects: >=0.4.7
deprecatedThe `pygraphviz` dependency, previously used for graph visualization, was replaced by `pydot` in v0.4.5 due to `pygraphviz`'s installation difficulties.
fix
If you rely on graph visualization features, ensure `pydot` is installed (`pip install pydot`) and update any code that might have directly interacted with `pygraphviz` utilities, though the library generally abstracts this.
affects: >=0.4.5
gotchaSupport for `Numpy 2` was implemented in v0.4.5. While this is a feature, users with very old `Numpy` versions (e.g., pre-1.19.x) might encounter compatibility issues, as the library evolved to support newer `Numpy` APIs.
fix
Ensure `Numpy` is updated to a modern, supported version. The library aims for broad `Numpy` compatibility but always benefits from recent `Numpy` releases.
affects: <0.4.5
gotchaIn v0.4.6, `trimesh` was briefly and incorrectly added as a required dependency, leading to unexpected installations for some users. This was quickly fixed.
fix
If you encountered this issue, upgrading to v0.4.7 or later will remove the unintended `trimesh` dependency unless explicitly requested as an optional extra.
affects: 0.4.6
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'colour.plotting' OR ImportError: cannot import name 'Color' from 'colour'
This error typically occurs when a user has installed a different Python package also named `colour` (e.g., `pip install colour`) instead of the `colour-science` library, or a naming conflict exists, preventing the correct `colour-science` modules from being imported.
fix
First, uninstall any conflicting 'colour' packages: `pip uninstall colour`. Then, ensure `colour-science` is correctly installed: `pip install colour-science`. Finally, import the library using `import colour`.
AttributeError: module 'colour' has no attribute 'CCS_ILLUMINANTS'
This `AttributeError` often indicates that an older version of `colour-science` is installed, where the specific attribute or function (like `CCS_ILLUMINANTS` or `SDS_ILLUMINANTS`) did not yet exist or had a different name. It can also stem from the `colour` package conflict described in the `ModuleNotFoundError` entry.
fix
Upgrade `colour-science` to the latest version to access newer APIs: `pip install --upgrade colour-science`. If a `colour` package conflict is suspected, resolve it as described in the `ModuleNotFoundError` fix.
ValueError: Tristimulus values conversion from spectral data according to practise "ASTM E308-15" should be performed on spectral data with measurement interval of 1, 5, 10 or 20nm!
This error occurs when attempting to perform tristimulus value conversion from spectral data using the 'ASTM E308-15' practice, but the input spectral data does not have one of the required wavelength measurement intervals (1nm, 5nm, 10nm, or 20nm).
fix
Before passing the spectral data to the conversion function, resample or interpolate it to one of the specified measurement intervals (1, 5, 10, or 20 nm). The library provides utilities for spectral data manipulation.
TypeError: 'numpy.float64' object cannot be interpreted as an integer
This `TypeError`, particularly encountered during the initial `import colour` statement, is typically a compatibility issue between an older version of `colour-science` and a specific combination of Python (e.g., 3.8.1) and `numpy` versions.
fix
Update `colour-science` and `numpy` to their latest stable versions: `pip install --upgrade colour-science numpy`. This issue was a known bug in older releases that has since been addressed.
Upgrade
Version history
0.4.7latest on PyPI · released Dec 6, 2025
Audit
Dependencies
numpyrequiredCore numerical operations and array handling.
scipyoptionalRequired for various signal processing and scientific computing functionalities. Made optional in v0.4.7.
imageiooptionalUsed for reading and writing image data. Made optional in v0.4.7.
pydotoptionalReplaced pygraphviz for graph visualisation functionalities due to easier installation. Used for generating colourspace diagrams.
trimeshoptionalMay be used for certain 3D mesh operations, though it was briefly (and incorrectly) a required dependency in v0.4.6.
Agent activity
52 hits · last 30 days
node
50
OpenAI (training)
1
Resources
colour-science — pip install colour-science · libregistry