cgohlke / imagecodecs

Image transformation, compression, and decompression codecs
https://pypi.org/project/imagecodecs
BSD 3-Clause "New" or "Revised" License
118 stars 23 forks source link

DelayedImportError: could not import name 'jpegxl_encode' from 'imagecodecs' #29

Closed JackKelly closed 2 years ago

JackKelly commented 2 years ago

Thanks so much for your work on this awesome library!

Sorry if I'm doing something wrong but I'm bumping into this exception with numcodecs 2021.11.20 (installed using conda today):

---------------------------------------------------------------------------
DelayedImportError                        Traceback (most recent call last)
Input In [29], in <module>
----> 1 encoded = jpegxl_encode(input_buffer, distance=0)

File ~/miniconda3/envs/jpegxl/lib/python3.10/site-packages/imagecodecs/imagecodecs.py:616, in _stub.<locals>.stub_encode(*args, **kwargs)
    614 def stub_encode(*args, **kwargs):
    615     """Stub for imagecodecs.codec_encode function."""
--> 616     raise DelayedImportError(name)

DelayedImportError: could not import name 'jpegxl_encode' from 'imagecodecs'

Steps to reproduce

conda install imagecodecs numpy

from imagecodecs import jpegxl_encode
import numpy as np

input_buffer = np.arange(1000000, dtype='uint8').reshape(1000, 1000)
encoded = jpegxl_encode(input_buffer, distance=0)

Context

I'm running this Python code in Jupyter Lab.

I installed libjxl v0.7.0 dev (compiling from HEAD, yesterday) before installing imagecodecs. cjxl appears to work correctly. I'm on Ubuntu 21.04.

I've also tried installing the libjxl 0.6.1 release now using the Ubuntu .deb file and re-installing imagecodecs but that didn't appear to help.

cgohlke commented 2 years ago

libjxl is currently not available in conda-forge and the jpegxl codec extension is not included in their imagecodecs builds. Please open an issue at https://github.com/conda-forge/imagecodecs-feedstock.

The jpegxl codec is functional in the Windows and 64-bit Linux wheels. On MacOS and 32-bit Linux libjxl would not build.

JackKelly commented 2 years ago

Thanks loads for the very quick reply! I'll try installing imagecodecs from pip! I have done as you suggested and submitted an issue: https://github.com/conda-forge/imagecodecs-feedstock/issues/48

Thanks again for all your hard work on imagecodecs!