Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing issue of xarray when using numpy 1.21 #5513

Closed
TiemoMathijssen opened this issue Jun 23, 2021 · 3 comments
Closed

Importing issue of xarray when using numpy 1.21 #5513

TiemoMathijssen opened this issue Jun 23, 2021 · 3 comments

Comments

@TiemoMathijssen
Copy link

After installing numpy v1.21, I have a problem importing xarray 0.18.2 in python3.7.9. This problem does not occur using numpy v1.20.3.

Steps to reproduce:

Numpy and xarray libraries are installed using pip3 install

Error message:

Python 3.7.9 (default, Apr 30 2021, 20:11:56)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-12)] on linux
Type "help", "copyright", "credits" or "license" for more information.

        import xarray
        Traceback (most recent call last):
        File "", line 1, in
        File "/home/rainbow/.local/lib/python3.7/site-packages/xarray/init.py", line 3, in
        from . import testing, tutorial, ufuncs
        File "/home/rainbow/.local/lib/python3.7/site-packages/xarray/testing.py", line 8, in
        from xarray.core import duck_array_ops, formatting, utils
        File "/home/rainbow/.local/lib/python3.7/site-packages/xarray/core/duck_array_ops.py", line 16, in
        from . import dask_array_compat, dask_array_ops, dtypes, npcompat, nputils
        File "/home/rainbow/.local/lib/python3.7/site-packages/xarray/core/npcompat.py", line 81, in
        from numpy.typing import ArrayLike, DTypeLike
        File "/home/rainbow/.local/lib/python3.7/site-packages/numpy/typing/init.py", line 315, in
        from ._shape import _Shape, _ShapeLike
        File "/home/rainbow/.local/lib/python3.7/site-packages/numpy/typing/_shape.py", line 15, in
        _ShapeLike = Union[SupportsIndex, Sequence[SupportsIndex]]
        File "/usr/lib64/python3.7/typing.py", line 254, in inner
        return func(*args, **kwds)
        File "/usr/lib64/python3.7/typing.py", line 634, in getitem
        params = tuple(_type_check(p, msg) for p in params)
        File "/usr/lib64/python3.7/typing.py", line 634, in
        params = tuple(_type_check(p, msg) for p in params)
        File "/usr/lib64/python3.7/typing.py", line 142, in _type_check
        raise TypeError(f"{msg} Got {arg!r:.100}.")
        TypeError: Parameters to generic types must be types. Got NotImplemented.
@shoyer
Copy link
Member

shoyer commented Jun 23, 2021

What happens if you write from numpy.typing import ArrayLike, DTypeLike without using Xarray at all? This looks a like it may be a NumPy installation issue, not directly related to Xarray.

@TiemoMathijssen
Copy link
Author

It is indeed a Numpy issue that occurs with python 3.7. I have posted the same issue on numpy/numpy#19310.

Quote:
"A fix for the issue is currently up at #19311 and should be in the next release.

In the meantime there two possible ways of remedying the situation:

Upgrade to python >=3.8.
Install typing-extensions.

"

@max-sixty
Copy link
Collaborator

Thanks @TiemoMathijssen . Closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants