diff --git a/src/zarr/storage/_fsspec.py b/src/zarr/storage/_fsspec.py index b294a9f75e..a40b2c6efd 100644 --- a/src/zarr/storage/_fsspec.py +++ b/src/zarr/storage/_fsspec.py @@ -3,8 +3,6 @@ import warnings from typing import TYPE_CHECKING, Any -from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper - from zarr.abc.store import ByteRangeRequest, Store from zarr.storage._common import _dereference_path @@ -169,7 +167,16 @@ def from_url( fs, path = url_to_fs(url, **opts) if not fs.async_impl: - fs = AsyncFileSystemWrapper(fs) + try: + from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper + + fs = AsyncFileSystemWrapper(fs) + except ImportError as e: + raise ImportError( + f"The filesystem for URL '{url}' is synchronous, and the required " + "AsyncFileSystemWrapper is not available. Upgrade fsspec to version " + "2024.12.0 or later to enable this functionality." + ) from e # fsspec is not consistent about removing the scheme from the path, so check and strip it here # https://github.com/fsspec/filesystem_spec/issues/1722