Skip to content

zarr import fails with undefined numcodecs.Zstd #2032

Closed
@mschubert

Description

@mschubert

Zarr version

v2.18.2

Numcodecs version

v0.12.1

zstd version

v1.5.6

Python Version

3.12

Operating System

Gentoo

Installation

custom ebuild

Description

After installing zarr, its import fails with:

>>> import zarr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.12/site-packages/zarr/__init__.py", line 2, in <module>
    from zarr.codecs import *
  File "/usr/lib/python3.12/site-packages/zarr/codecs.py", line 3, in <module>
    from numcodecs import get_codec, Blosc, Pickle, Zlib, Zstd, Delta, AsType, BZ2
ImportError: cannot import name 'Zstd' from 'numcodecs' (/usr/lib/python3.12/site-packages/numcodecs/__init__.py)

numcodecs does indeed not define Zstd, but either numcodecs.zstd or numcodecs.zstd.Zstd. If I understand correctly this symbol is created with:

# @numcodecs/__init__.py
with suppress(ImportError):
    from numcodecs import zstd
    from numcodecs.zstd import Zstd

    register_codec(Zstd)

However, if an error occurs here, the underlying message is never shown to the user. Would it make sense to be more transparent?

>>> from numcodecs import zstd
ImportError: /home/schubert/gentoo/usr/lib/python3.12/site-packages/numcodecs/zstd.cpython-312-x86_64-linux-gnu.so: undefined symbol: STD_compressBlock_btopt

Here the actual error is shown (an incompatibility with zstd=1.5.6? which should ideally be caught at compilation?)

Please note that this may be better addressed by numcodecs than zarr - if so, apologies for reporting to the wrong package.

Steps to reproduce

import zarr

Additional output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    V2Affects the v2 branchbugPotential 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