I'm trying to load some .nc files this way:
ds = xr.open_dataset('path/to/file.nc')
At first I get no error message, but when I try to operate or simply visualize the data I get this really long error message:
ds
---------------------------------------------------------------------------
InvalidVersion Traceback (most recent call last)
File ~\anaconda3\Lib\site-packages\IPython\core\formatters.py:406, in BaseFormatter.__call__(self, obj)
404 method = get_real_method(obj, self.print_method)
405 if method is not None:
--> 406 return method()
407 return None
408 else:
File ~\anaconda3\Lib\site-packages\xarray\core\dataset.py:2436, in Dataset._repr_html_(self)
2434 if OPTIONS["display_style"] == "text":
2435 return f"<pre>{escape(repr(self))}</pre>"
-> 2436 return formatting_html.dataset_repr(self)
File ~\anaconda3\Lib\site-packages\xarray\core\formatting_html.py:377, in dataset_repr(ds)
374 sections.append(dim_section(ds))
376 if ds.coords:
--> 377 sections.append(coord_section(ds.coords))
379 sections.append(datavar_section(ds.data_vars))
381 display_default_indexes = _get_boolean_with_default(
382 "display_default_indexes", False
383 )
File ~\anaconda3\Lib\site-packages\xarray\core\formatting_html.py:225, in _mapping_section(mapping, name, details_func, max_items_collapse, expand_option_name, enabled, **kwargs)
218 expanded = max_items_collapse is None or _get_boolean_with_default(
219 expand_option_name, n_items < max_items_collapse
220 )
221 collapsed = not expanded
223 return collapsible_section(
224 f"{name}:",
--> 225 details=details_func(mapping, **kwargs),
226 n_items=n_items,
227 enabled=enabled,
228 collapsed=collapsed,
229 )
File ~\anaconda3\Lib\site-packages\xarray\core\formatting_html.py:127, in summarize_coords(variables)
123 dim_ordered_coords = sorted(
124 variables.items(), key=partial(_coord_sort_key, dims=dims)
125 )
126 for k, v in dim_ordered_coords:
--> 127 li_content = summarize_variable(k, v, is_index=k in variables.xindexes)
128 li_items.append(f"<li class='xr-var-item'>{li_content}</li>")
130 vars_li = "".join(li_items)
File ~\anaconda3\Lib\site-packages\xarray\core\formatting_html.py:96, in summarize_variable(name, var, is_index, dtype)
93 data_id = "data-" + str(uuid.uuid4())
94 disabled = "" if len(var.attrs) else "disabled"
---> 96 preview = escape(inline_variable_array_repr(variable, 35))
97 attrs_ul = summarize_attrs(var.attrs)
98 data_repr = short_data_repr_html(variable)
File ~\anaconda3\Lib\site-packages\xarray\core\formatting.py:316, in inline_variable_array_repr(var, max_width)
314 if getattr(var, "_in_memory", False):
315 return format_array_flat(var, max_width)
--> 316 dask_array_type = array_type("dask")
317 if isinstance(var._data, dask_array_type):
318 return inline_dask_repr(var.data)
File ~\anaconda3\Lib\site-packages\xarray\namedarray\pycompat.py:83, in array_type(mod)
81 def array_type(mod: ModType) -> DuckArrayTypes:
82 """Quick wrapper to get the array class of the module."""
---> 83 return _get_cached_duck_array_module(mod).type
File ~\anaconda3\Lib\site-packages\xarray\namedarray\pycompat.py:74, in _get_cached_duck_array_module(mod)
72 def _get_cached_duck_array_module(mod: ModType) -> DuckArrayModule:
73 if mod not in _cached_duck_array_modules:
---> 74 duckmod = DuckArrayModule(mod)
75 _cached_duck_array_modules[mod] = duckmod
76 return duckmod
File ~\anaconda3\Lib\site-packages\xarray\namedarray\pycompat.py:40, in DuckArrayModule.__init__(self, mod)
38 try:
39 duck_array_module = import_module(mod)
---> 40 duck_array_version = Version(duck_array_module.__version__)
42 if mod == "dask":
43 duck_array_type = (import_module("dask.array").Array,)
File ~\anaconda3\Lib\site-packages\packaging\version.py:202, in Version.__init__(self, version)
200 match = self._regex.search(version)
201 if not match:
--> 202 raise InvalidVersion(f"Invalid version: {version!r}")
204 # Store the parsed out pieces of the version
205 self._version = _Version(
206 epoch=int(match.group("epoch")) if match.group("epoch") else 0,
207 release=tuple(int(i) for i in match.group("release").split(".")),
(...) 213 local=_parse_local_version(match.group("local")),
214 )
InvalidVersion: Invalid version: 'unknown'
(this isn't actually the full message, but it wouldn't let me submit with such a long code section)
I tried looking for answers but couldn't find anyone with the same error message.
dask. Maybe it has wrong version. You could checkdask.__version__anaconda3. You could with normal Python.