Skip to content

Can't import zarr<3 with latest numcodecs==0.16.0 #2963

Closed

Description

@ryan-williams

Zarr version

v2.18.5

Numcodecs version

v0.16.0

Python Version

3.11 (but probably all)

Operating System

Ubuntu and Mac (but probably all)

Installation

pip install 'zarr<3' numcodecs

Description

In zarr<3, zarr/util.py imports numcodecs.blosc.cbuffer_sizes (e.g. here in 2.18.5), which was removed in numcodecs 0.16.0 (released 40mins ago at time of writing)

This reference was removed in #2182, prior to 3.0.0, but causes zarr 2.x to fail to import when latest numcodecs is installed; GHA example:

  File "/home/runner/work/TileDB-SOMA/TileDB-SOMA/venv-soma/lib/python3.11/site-packages/zarr/convenience.py", line 8, in <module>
    from zarr._storage.store import data_root, meta_root, assert_zarr_v3_api_available
  File "/home/runner/work/TileDB-SOMA/TileDB-SOMA/venv-soma/lib/python3.11/site-packages/zarr/_storage/store.py", line 10, in <module>
    from zarr.meta import Metadata2, Metadata3
  File "/home/runner/work/TileDB-SOMA/TileDB-SOMA/venv-soma/lib/python3.11/site-packages/zarr/meta.py", line 10, in <module>
    from zarr.util import json_dumps, json_loads
  File "/home/runner/work/TileDB-SOMA/TileDB-SOMA/venv-soma/lib/python3.11/site-packages/zarr/util.py", line 34, in <module>
    from numcodecs.blosc import cbuffer_sizes, cbuffer_metainfo
ImportError: cannot import name 'cbuffer_sizes' from 'numcodecs.blosc' (/home/runner/work/TileDB-SOMA/TileDB-SOMA/venv-soma/lib/python3.11/site-packages/numcodecs/blosc.cpython-311-x86_64-linux-gnu.so)
Error: Process completed with exit code 1.

Not sure it's worth a 2.18.6 to pin numcodecs<0.16 (or remove the offending references), just flagging the issue.

Steps to reproduce

python -m venv .venv
. .venv/bin/activate
pip install 'zarr<3' numcodecs
python -c 'import zarr'  # ❌ ImportError: cannot import name 'cbuffer_sizes' from 'numcodecs.blosc' (/Users/ryan/c/single-cell-data/tiledb-soma/tmp/.venv/lib/python3.11/site-packages/numcodecs/blosc.cpython-311-darwin.so)

or:

docker run --rm --entrypoint bash python:3.11 -c 'pip install "zarr<3" numcodecs && python -c "import zarr"'
# ❌ ImportError: cannot import name 'cbuffer_sizes' from 'numcodecs.blosc' (/usr/local/lib/python3.11/site-packages/numcodecs/blosc.cpython-311-x86_64-linux-gnu.so)

Additional output

No response

Activity

  1. added
    bugPotential issues with the zarr-python library
    on Apr 7, 2025
  2. dstansby commented on Apr 7, 2025

    @dstansby
    Contributor

    Thanks for the quick report, and sorry about this. I think the best thing to do is pin numcodecs here, I'll do that now.

  3. cspades commented on Apr 7, 2025

    @cspades

    Also hit this error, which affects NeMo:

    /__w/_tool/Python/3.12.9/x64/lib/python3.12/site-packages/zarr/meta.py:10: in <module>
        from zarr.util import json_dumps, json_loads
    /__w/_tool/Python/3.12.9/x64/lib/python3.12/site-packages/zarr/util.py:34: in <module>
        from numcodecs.blosc import cbuffer_sizes, cbuffer_metainfo
    E   ImportError: cannot import name 'cbuffer_sizes' from 'numcodecs.blosc' (/__w/_tool/Python/3.12.9/x64/lib/python3.12/site-packages/numcodecs/blosc.cpython-312-x86_64-linux-gnu.so)
    

    Following for the fix, thank you!

  4. dstansby commented on Apr 8, 2025

    @dstansby
    Contributor

    This should now be fixed with a new 2.18.6 release - would be great if someone could confirm before we close this.

  5. tcompa commented on Apr 8, 2025

    @tcompa

    Hi there

    This should now be fixed with a new 2.18.6 release - would be great if someone could confirm before we close this.

    Something is still not working for me:

    $ python --version
    Python 3.11.11
    
    $ pip install "zarr<3" numcodecs
    [...]
    
    $ pip freeze
    asciitree==0.3.3
    fasteners==0.19
    numcodecs==0.16.0
    numpy==2.2.4
    typing_extensions==4.13.1
    zarr==2.18.6
    

    At a first look, I think that this is because #2965 modified the docs entry for numcodecs (https://github.com/zarr-developers/zarr-python/blob/support/v2/pyproject.toml#L45), rather than the actual line (https://github.com/zarr-developers/zarr-python/blob/support/v2/pyproject.toml#L16).

  6. dstansby commented on Apr 8, 2025

    @dstansby
    Contributor

    😱 thanks for checking - working on a working fix...

  7. gastoneb commented on Apr 8, 2025

    @gastoneb

    Experiencing the same issue even with older zarr versions. Workaround until a fix is available is to explicitly require numcodecs==0.15.0 in your deps, since it will always try to install 0.16 otherwise.

  8. dstansby commented on Apr 9, 2025

    @dstansby
    Contributor

    Right, I'm pretty sure this is fixed now - just did a fresh install, and with zarr 2.18.7 it pulls numcodecs 0.15.1. Could someone else double check? Sorry again for the disruption.

  9. schenker commented on Apr 9, 2025

    @schenker

    With zarr 2.18.7 it works as expected, thanks!

  10. 4 remaining items

  11. added a commit that references this issue on Apr 9, 2025
  12. added a commit that references this issue on Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions