Description
What happened?
Fail to import xarray when xarray 2022.6.0 and numpy 1.20 are installed. It seems xarray 2022.6.0 is not compatible with numpy 1.20. I also tried numpy 1.19 and 1.21, they all work well with xarray 2022.6.0.
What did you expect to happen?
xarray 2022.6.0 should work well with numpy 1.20.
Minimal Complete Verifiable Example
$ conda create --name xarraytest xarray=2022.6.0 numpy=1.20
$ conda activate xarraytest
$ conda list
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_gnu conda-forge
bzip2 1.0.8 h7f98852_4 conda-forge
ca-certificates 2022.6.15 ha878542_0 conda-forge
importlib-metadata 4.11.4 py39hf3d152e_0 conda-forge
importlib_metadata 4.11.4 hd8ed1ab_0 conda-forge
ld_impl_linux-64 2.36.1 hea4e1c9_2 conda-forge
libblas 3.9.0 15_linux64_openblas conda-forge
libcblas 3.9.0 15_linux64_openblas conda-forge
libffi 3.4.2 h7f98852_5 conda-forge
libgcc-ng 12.1.0 h8d9b700_16 conda-forge
libgfortran-ng 12.1.0 h69a702a_16 conda-forge
libgfortran5 12.1.0 hdcd56e2_16 conda-forge
libgomp 12.1.0 h8d9b700_16 conda-forge
liblapack 3.9.0 15_linux64_openblas conda-forge
libnsl 2.0.0 h7f98852_0 conda-forge
libopenblas 0.3.20 pthreads_h78a6416_0 conda-forge
libstdcxx-ng 12.1.0 ha89aaad_16 conda-forge
libuuid 2.32.1 h7f98852_1000 conda-forge
libzlib 1.2.12 h166bdaf_2 conda-forge
ncurses 6.3 h27087fc_1 conda-forge
numpy 1.20.3 py39hd249d9e_2 conda-forge
openssl 3.0.5 h166bdaf_0 conda-forge
packaging 21.3 pyhd8ed1ab_0 conda-forge
pandas 1.4.3 py39h1832856_0 conda-forge
pip 22.2 pyhd8ed1ab_0 conda-forge
pyparsing 3.0.9 pyhd8ed1ab_0 conda-forge
python 3.9.13 h2660328_0_cpython conda-forge
python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge
python_abi 3.9 2_cp39 conda-forge
pytz 2022.1 pyhd8ed1ab_0 conda-forge
readline 8.1.2 h0f457ee_0 conda-forge
setuptools 63.2.0 py39hf3d152e_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
sqlite 3.39.2 h4ff8645_0 conda-forge
tk 8.6.12 h27826a3_0 conda-forge
typing_extensions 4.3.0 pyha770c72_0 conda-forge
tzdata 2022a h191b570_0 conda-forge
wheel 0.37.1 pyhd8ed1ab_0 conda-forge
xarray 2022.6.0 pyhd8ed1ab_0 conda-forge
xz 5.2.5 h516909a_1 conda-forge
zipp 3.8.0 pyhd8ed1ab_0 conda-forge
zlib 1.2.12 h166bdaf_2 conda-forge
$ python
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xarray as xr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/miniconda/envs/xarraytest/lib/python3.9/site-packages/xarray/__init__.py", line 1, in <module>
from . import testing, tutorial
File "/home/user/miniconda/envs/xarraytest/lib/python3.9/site-packages/xarray/testing.py", line 9, in <module>
from xarray.core import duck_array_ops, formatting, utils
File "/home/user/miniconda/envs/xarraytest/lib/python3.9/site-packages/xarray/core/duck_array_ops.py", line 26, in <module>
from . import dask_array_compat, dask_array_ops, dtypes, npcompat, nputils
File "/home/user/miniconda/envs/xarraytest/lib/python3.9/site-packages/xarray/core/npcompat.py", line 72, in <module>
_SupportsDType[np.dtype],
File "/home/user/miniconda/envs/xarraytest/lib/python3.9/typing.py", line 277, in inner
return func(*args, **kwds)
File "/home/user/miniconda/envs/xarraytest/lib/python3.9/typing.py", line 1004, in __class_getitem__
_check_generic(cls, params, len(cls.__parameters__))
File "/home/user/miniconda/envs/xarraytest/lib/python3.9/site-packages/typing_extensions.py", line 92, in _check_generic
raise TypeError(f"{cls} is not a generic class")
TypeError: <class 'numpy.typing._dtype_like._SupportsDType'> is not a generic class
>>>
MVCE confirmation
- Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- Complete example — the example is self-contained, including all data and the text of any traceback.
- Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
- New issue — a search of GitHub Issues suggests this is not a duplicate.
Relevant log output
No response
Anything else we need to know?
No response