Skip to content

feat(oklch): added oklch to color picker options#97

Open
fnielson1 wants to merge 4 commits intostuartlangridge:appfrom
fnielson1:app
Open

feat(oklch): added oklch to color picker options#97
fnielson1 wants to merge 4 commits intostuartlangridge:appfrom
fnielson1:app

Conversation

@fnielson1
Copy link

I added an option to format the color value as oklch

@stuartlangridge
Copy link
Owner

OK, I tried running this, but it doesn't seem to work; the relative imports don't seem right. When I do python -m pick (which is how to run pick), it throws: ModuleNotFoundError: No module named 'colour'
I did wonder if it was as simple as a relative import thing (so it should be from .colour.models import sRGB_to_XYZ, XYZ_to_Oklab instead with the extra . at the start) but I don't think it is, so I'm not sure what's up there.

@fnielson1
Copy link
Author

fnielson1 commented Jan 21, 2026

OK, I tried running this, but it doesn't seem to work; the relative imports don't seem right. When I do python -m pick (which is how to run pick), it throws: ModuleNotFoundError: No module named 'colour' I did wonder if it was as simple as a relative import thing (so it should be from .colour.models import sRGB_to_XYZ, XYZ_to_Oklab instead with the extra . at the start) but I don't think it is, so I'm not sure what's up there.

@stuartlangridge
I added colour as a requirement in the setup.py. Does it now warn/install the colour package? I'm not exactly familiar with setup.py

@stuartlangridge
Copy link
Owner

Unless I'm missing something very obvious, that isn't working? I installed python3-colour from the Ubuntu archives, and that seems to be the same package as https://pypi.org/project/colour/, and it works:

$ python -c "import colour; print(colour.Color)"
<class 'colour.Color'>

but there is no colour.models:

09:22 ~/S+/ColourPicker (fnielson1/app) $ python -m pick
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/aquarius/Scratch/ColourPicker/pick/__main__.py", line 10, in <module>
    from .converters import rgb_to_lab, rgb_to_oklch, deltaE, LAB_COLOUR_NAMES
  File "/home/aquarius/Scratch/ColourPicker/pick/converters.py", line 4, in <module>
    from colour.models import sRGB_to_XYZ, XYZ_to_Oklab
ModuleNotFoundError: No module named 'colour.models'; 'colour' is not a package

is it a different external package? I am confused: it's quite possible I'm doing something very wrong here, but I don't know what.

@frank-nielson
Copy link

frank-nielson commented Jan 21, 2026

Hmmm... Lovely. I'll try it in a new environment and see exactly what I did to get it and I'll get back to you. Thanks for keeping at it!

@fnielson1
Copy link
Author

Got it @stuartlangridge ! You need to run:

pip3 install colour-science

or in my case, since I'm using a virtual python environment:

.venv/bin/pip3 install colour-science

@stuartlangridge
Copy link
Owner

OK, I've now tried this, and it didn't work for different reasons (and I'm not sure why; some sort of library incompatibility that I don't understand):

$ python -m venv --system-site-packages ./venv
$ source ./venv/bin/activate
$ python -m pick
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/aquarius/Scratch/ColourPicker/pick/__main__.py", line 10, in <module>
    from .converters import rgb_to_lab, rgb_to_oklch, deltaE, LAB_COLOUR_NAMES
  File "/home/aquarius/Scratch/ColourPicker/pick/converters.py", line 4, in <module>
    from colour.models import sRGB_to_XYZ, XYZ_to_Oklab
ModuleNotFoundError: No module named 'colour.models'; 'colour' is not a package

# ok, so we install it as suggested

$ pip3 install colour-science
Collecting colour-science
  Downloading colour_science-0.4.7-py3-none-any.whl.metadata (59 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59.3/59.3 kB 2.8 MB/s eta 0:00:00
Collecting numpy<3,>=2.0.0 (from colour-science)
  Downloading numpy-2.4.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (6.6 kB)
Downloading colour_science-0.4.7-py3-none-any.whl (9.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.1/9.1 MB 11.4 MB/s eta 0:00:00
Downloading numpy-2.4.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.4 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.4/16.4 MB 11.4 MB/s eta 0:00:00
Installing collected packages: numpy, colour-science
  Attempting uninstall: numpy
    Found existing installation: numpy 1.26.4
    Not uninstalling numpy at /usr/lib/python3/dist-packages, outside environment /home/aquarius/Scratch/ColourPicker/venv
    Can't uninstall 'numpy'. No files were found to uninstall.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
types-seaborn 0.13 requires pandas-stubs, which is not installed.
scipy 1.11.4 requires numpy<1.28.0,>=1.21.6, but you have numpy 2.4.1 which is incompatible.
types-seaborn 0.13 requires matplotlib>=3.8, but you have matplotlib 3.6.3 which is incompatible.
Successfully installed colour-science-0.4.7 numpy-2.4.1

# and now try running pick again

$ python -m pick
/usr/lib/python3/dist-packages/scipy/__init__.py:132: UserWarning: A NumPy version >=1.21.6 and <1.28.0 is required for this version of SciPy (detected version 2.4.1)
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/aquarius/Scratch/ColourPicker/pick/__main__.py", line 10, in <module>
    from .converters import rgb_to_lab, rgb_to_oklch, deltaE, LAB_COLOUR_NAMES
  File "/home/aquarius/Scratch/ColourPicker/pick/converters.py", line 4, in <module>
    from colour.models import sRGB_to_XYZ, XYZ_to_Oklab
  File "/home/aquarius/Scratch/ColourPicker/venv/lib/python3.12/site-packages/colour/__init__.py", line 72, in <module>
    from colour import plotting  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aquarius/Scratch/ColourPicker/venv/lib/python3.12/site-packages/colour/plotting/__init__.py", line 1, in <module>
    from colour.utilities import is_matplotlib_installed
  File "/home/aquarius/Scratch/ColourPicker/venv/lib/python3.12/site-packages/colour/utilities/__init__.py", line 150, in <module>
    from .metrics import metric_mse, metric_psnr
  File "/home/aquarius/Scratch/ColourPicker/venv/lib/python3.12/site-packages/colour/utilities/metrics.py", line 25, in <module>
    from colour.algebra import sdiv, sdiv_mode
  File "/home/aquarius/Scratch/ColourPicker/venv/lib/python3.12/site-packages/colour/algebra/__init__.py", line 39, in <module>
    from .interpolation import (
  File "/home/aquarius/Scratch/ColourPicker/venv/lib/python3.12/site-packages/colour/algebra/interpolation.py", line 92, in <module>
    import scipy.interpolate
  File "/usr/lib/python3/dist-packages/scipy/interpolate/__init__.py", line 167, in <module>
    from ._interpolate import *
  File "/usr/lib/python3/dist-packages/scipy/interpolate/_interpolate.py", line 9, in <module>
    import scipy.special as spec
  File "/usr/lib/python3/dist-packages/scipy/special/__init__.py", line 772, in <module>
    from . import _ufuncs
  File "scipy/special/_ufuncs.pyx", line 1, in init scipy.special._ufuncs
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

@frank-nielson
Copy link

That is so weird. Ugh. I'm probably gonna have to find a different library.

@fnielson1
Copy link
Author

Alright. I made a bunch of changes. I moved the icons in preparation for moving from setuptools to pypa/build. The important part is I updated the readme.md and added a setup.sh that will install all needed deps.
I tested this by doing a clean clone from my branch and following the steps in the readme (including setting up venv).
After that, python -m pick ran correctly.
I really, really hope it works this time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants