Repository navigation
Closed
Labels
Description
What happened?
On Windows, xr.open_dataset() raises PermissionError for a readable local Zarr directory during engine detection. The traceback comes from the netCDF4 backend trying to open the directory as a file.
Specifying engine="zarr" or using xr.open_zarr() works.
Expected behavior
Automatically detect and open the Zarr store.
Minimal example
from pathlib import Path
from tempfile import TemporaryDirectory
import xarray as xr
with TemporaryDirectory() as temporary_directory:
store = Path(temporary_directory) / "example.zarr"
xr.Dataset({"temperature": ("time", [1.0, 2.0, 3.0])}).to_zarr(
store, zarr_format=2
)
with xr.open_dataset(store, engine="zarr", chunks={}) as dataset:
assert dataset.temperature.compute().values.tolist() == [1.0, 2.0, 3.0]
with xr.open_zarr(store, chunks={}) as dataset:
assert dataset.temperature.compute().values.tolist() == [1.0, 2.0, 3.0]
xr.open_dataset(store, chunks={}) # Raises PermissionError on WindowsTraceback
Traceback (most recent call last):
File "<reproducer>", in <module>
xr.open_dataset(store, chunks={})
File "<site-packages>/xarray/backends/api.py", line 600, in open_dataset
engine = plugins.guess_engine(filename_or_obj)
File "<site-packages>/xarray/backends/plugins.py", line 154, in guess_engine
if backend.guess_can_open(store_spec):
File "<site-packages>/xarray/backends/netCDF4_.py", line 764, in guess_can_open
magic_number = try_read_magic_number_from_path(filename_or_obj)
File "<site-packages>/xarray/core/utils.py", line 784, in try_read_magic_number_from_path
with open(path, "rb") as f:
PermissionError: [Errno 13] Permission denied: '<temporary-directory>\example.zarr'Environment
Windows 11, Python 3.13.15, xarray 2026.9.0, netCDF4 1.7.4, zarr 3.4.1. Not tested against the development branch.
Installed versions (xr.show_versions())
commit: None
python: 3.13.15 (tags/v3.13.15:4061bc4, Aug 5 2026, 13:05:39) [MSC v.1944 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 11
machine: AMD64
processor: AMD64 Family 26 Model 96 Stepping 0, AuthenticAMD
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: (English_United States, 1252)
libhdf5: 1.14.6
libnetcdf: 4.9.3
xarray: 2026.9.0
pandas: 3.0.6
numpy: 2.5.4
scipy: 1.18.1
netCDF4: 1.7.4
pydap: 3.5.11
h5netcdf: 1.8.1
h5py: 3.16.0
zarr: 3.4.1
cftime: 1.6.6
nc_time_axis: None
iris: None
bottleneck: None
dask: 2026.8.0
distributed: None
matplotlib: 3.11.2
cartopy: 0.26.0
seaborn: 0.13.2
numbagg: None
fsspec: 2026.9.0
cupy: None
pint: 0.26.1
sparse: None
flox: None
numpy_groupies: None
setuptools: None
pip: 26.2.1
conda: None
pytest: 9.1.1
mypy: None
IPython: 9.17.1
sphinx: None
Activity
welcome commentedon Oct 23, 2026
Thanks for opening your first issue here at xarray! Be sure to follow the issue template!
If you have an idea for a solution, we would really welcome a Pull Request with proposed changes.
See the Contributing Guide for more.
It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better.
Thank you!