Skip to content

[Bug] ModuleNotFoundError with xarray >= v2025.03.0 #566

@jskrzypek

Description

@jskrzypek

Xarray's v2025.03.0 release last week seems to have included a breaking change that results in cf_xarray erroring out on import.

After I updated our dependencies today, xarray got bumped from v2025.01.2 to v2025.03.0, and I starting seeing this error in my stack trace:

my/code/common/io.py:16: in <module>
    from cf_xarray import decode_compress_to_multi_index, encode_multi_index_as_compress
.venv/lib/python3.11/site-packages/cf_xarray/__init__.py:2: in <module>
    from .accessor import CFAccessor  # noqa
.venv/lib/python3.11/site-packages/cf_xarray/accessor.py:27: in <module>
    from xarray.core.arithmetic import SupportsArithmetic
E   ModuleNotFoundError: No module named 'xarray.core.arithmetic'

When I pin the constraint for xarray to xarray >= 2023.10.1, < 2025.3.0 I no longer see this issue, so I have a good workaround, just wanted to make sure to report in case you have the appetite to fix the issue or other followers encounter the same problem.

You can see the problematic file move in question here (xarray/core/arithmetic.py → xarray/computation/arithmetic.py). There may be others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions