Skip to content

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

Open
fnielson1 wants to merge 4 commits into
stuartlangridge:appfrom
fnielson1:app
Open

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

Conversation

@fnielson1

Copy link
Copy Markdown

I added an option to format the color value as oklch

@stuartlangridge

Copy link
Copy Markdown
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

fnielson1 commented Jan 21, 2026

Copy link
Copy Markdown
Author

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
Copy Markdown
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

frank-nielson commented Jan 21, 2026

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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

@fnielson1

Copy link
Copy Markdown
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

@fnielson1

Copy link
Copy Markdown
Author

@stuartlangridge If you get latest on my branch, you run setup.sh, which will install all the necessary deps. The readme has the steps outlined.
After that, python -m pick should work.

@stuartlangridge

Copy link
Copy Markdown
Owner

OK, I tried this, and got the same numpy complaints as before. I'm in a venv with system-site-packages included:

$ bash setup.sh 
Installing Python dependencies:
colour-science

---
Running: pip install colour-science
Requirement already satisfied: colour-science in ./venv/lib/python3.12/site-packages (0.4.7)
Requirement already satisfied: numpy<3,>=2.0.0 in ./venv/lib/python3.12/site-packages (from colour-science) (2.4.4)

Installing system dependencies with apt-get (requires sudo):
  gir1.2-dee-1.0   gir1.2-gdkpixbuf-2.0   gir1.2-glib-2.0   gir1.2-gtk-3.0   gir1.2-unity-7.0   python3-cairo   python3-gi   python3-gi-cairo  

---
Hit:1 https://download.docker.com/linux/ubuntu noble InRelease
Hit:2 http://gb.archive.ubuntu.com/ubuntu noble InRelease                      
Hit:3 http://gb.archive.ubuntu.com/ubuntu noble-updates InRelease              
Ign:4 https://repo.vivaldi.com/stable/deb stable InRelease                     
Hit:5 http://gb.archive.ubuntu.com/ubuntu noble-backports InRelease            
Hit:6 https://dl.google.com/linux/chrome-stable/deb stable InRelease           
Hit:7 https://updates.signal.org/desktop/apt xenial InRelease                  
Hit:8 http://security.ubuntu.com/ubuntu noble-security InRelease               
Hit:9 https://repo.vivaldi.com/stable/deb stable Release                       
Hit:11 https://download.sublimetext.com apt/stable/ InRelease                  
Hit:12 https://packages.microsoft.com/repos/edge stable InRelease
Reading package lists... Done
N: Skipping acquire of configured file 'stable/binary-i386/Packages' as repository 'https://download.docker.com/linux/ubuntu noble InRelease' doesn't support architecture 'i386'
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://dl.google.com/linux/chrome-stable/deb stable InRelease' doesn't support architecture 'i386'
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://repo.vivaldi.com/stable/deb stable InRelease' doesn't support architecture 'i386'
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://packages.microsoft.com/repos/edge stable InRelease' doesn't support architecture 'i386'
N: Missing Signed-By in the sources.list(5) entry for 'https://repo.vivaldi.com/stable/deb'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
gir1.2-dee-1.0 is already the newest version (1.2.7+17.10.20170616-7build5).
gir1.2-gdkpixbuf-2.0 is already the newest version (2.42.10+dfsg-3ubuntu3.3).
gir1.2-glib-2.0 is already the newest version (2.80.0-6ubuntu3.8).
gir1.2-gtk-3.0 is already the newest version (3.24.41-4ubuntu1.3).
gir1.2-unity-7.0 is already the newest version (7.1.4+19.04.20190319-6build4).
python3-cairo is already the newest version (1.25.1-2build2).
python3-gi is already the newest version (3.48.2-1).
python3-gi-cairo is already the newest version (3.48.2-1).
The following packages were automatically installed and are no longer required:
  libnvidia-cfg1-570 libnvidia-common-570 libnvidia-compute-570
  libnvidia-decode-570 libnvidia-encode-570 libnvidia-extra-570
  libnvidia-fbc1-570 libnvidia-gl-570 nvidia-compute-utils-570
  nvidia-firmware-570-570.211.01 nvidia-kernel-source-570-open
  nvidia-utils-570 xserver-xorg-video-nvidia-570
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
(venv) 07:45 ~/S+/ColourPicker (app) $ python3 -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.4)
  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 11, 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

I'm not sure what I'm meant to do here?

@fnielson1

Copy link
Copy Markdown
Author

Darn. I appreciate you trying it again. I'll try to see what I need to do. I wish I could replicate it

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