Skip to content

rich is not a dependency of zarr but is required by zarr.Group.tree() function #2932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
flyingfalling opened this issue Mar 26, 2025 · 4 comments
Labels
bug Potential issues with the zarr-python library

Comments

@flyingfalling
Copy link

flyingfalling commented Mar 26, 2025

Zarr version

3.0.6

Numcodecs version

0.15.1

Python Version

3.13

Operating System

Linux

Installation

pip install zarr

Description

rich is not a dependency of zarr but is required by zarr.Group.tree() function

The following code raises an exception (due to "import rich" in tree()) despite being minimal example:

Here is the full traceback:

root.tree()

Traceback (most recent call last):
  File "/home/riveale/zarrvenv/lib64/python3.13/site-packages/zarr/core/_tree.py", line 9, in <module>
    import rich
ModuleNotFoundError: No module named 'rich'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    root.tree()
    ~~~~~~~~~^^
  File "/home/riveale/zarrvenv/lib64/python3.13/site-packages/zarr/core/group.py", line 2300, in tree
    return self._sync(self._async_group.tree(expand=expand, level=level))
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/riveale/zarrvenv/lib64/python3.13/site-packages/zarr/core/sync.py", line 208, in _sync
    return sync(
        coroutine,
        timeout=config.get("async.timeout"),
    )
  File "/home/riveale/zarrvenv/lib64/python3.13/site-packages/zarr/core/sync.py", line 163, in sync
    raise return_result
  File "/home/riveale/zarrvenv/lib64/python3.13/site-packages/zarr/core/sync.py", line 119, in _runner
    return await coro
           ^^^^^^^^^^
  File "/home/riveale/zarrvenv/lib64/python3.13/site-packages/zarr/core/group.py", line 1550, in tree
    from zarr.core._tree import group_tree_async
  File "/home/riveale/zarrvenv/lib64/python3.13/site-packages/zarr/core/_tree.py", line 13, in <module>
    raise ImportError("'rich' is required for Group.tree") from e
ImportError: 'rich' is required for Group.tree

Steps to reproduce

import zarr;

root = zarr.create_group(store='test.zarr');

root.tree();

Additional output

No response

@flyingfalling flyingfalling added the bug Potential issues with the zarr-python library label Mar 26, 2025
@d-v-b
Copy link
Contributor

d-v-b commented Mar 26, 2025

rich is an optional dependency, and you can install it with zarr with pip install zarr[optional], but this is not at all intuitive. we should probably come up with a better name for this, and update that import error

@d-v-b
Copy link
Contributor

d-v-b commented Mar 26, 2025

looks like this has been discussed in the past:
#2539
#2541

@flyingfalling
Copy link
Author

@d-v-b Hey I was just preparing a pull request and I noticed that it is in the [test] and [optional] in the .toml et cetera. Yea...not much to do about this if you don't want to pull it for normal installations. I don't know the right pythontic way to deal with this kind of thing.

@flyingfalling
Copy link
Author

Anyways, thanks for pointing to the old issues. It seems this is "expected behavior", so I will close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library
Projects
None yet
Development

No branches or pull requests

2 participants