Bug#960380: python3-xarray: Import fails if python3-sparse is also installed

Mika Pflüger debian at mikapflueger.de
Mon May 11 21:16:46 BST 2020


Package: python3-xarray
Version: 0.15.1-2
Severity: normal

Hi,

if python3-xarray and python3-sparse are both installed, importing xarray fails with
an AttributeError, because xarray uses an unqualified "import sparse" trying to
import an internal package. The internal package is shadowed by python3-sparse,
which does not have the same API as xarray's internal package.

The full backtrace in ipython3 is:

22:09:205:~> ipython3
Python 3.8.3rc1 (default, Apr 30 2020, 07:33:30) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import xarray as xr                                                                
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-b027d314c3e9> in <module>
----> 1 import xarray as xr

/usr/lib/python3/dist-packages/xarray/__init__.py in <module>
      1 import pkg_resources
      2 
----> 3 from . import testing, tutorial, ufuncs
      4 from .backends.api import (
      5     load_dataarray,

/usr/lib/python3/dist-packages/xarray/testing.py in <module>
      5 import pandas as pd
      6 
----> 7 from xarray.core import duck_array_ops, formatting
      8 from xarray.core.dataarray import DataArray
      9 from xarray.core.dataset import Dataset

/usr/lib/python3/dist-packages/xarray/core/duck_array_ops.py in <module>
     12 import pandas as pd
     13 
---> 14 from . import dask_array_compat, dask_array_ops, dtypes, npcompat, nputils
     15 from .nputils import nanfirst, nanlast
     16 from .pycompat import dask_array_type

/usr/lib/python3/dist-packages/xarray/core/dask_array_compat.py in <module>
      5 import numpy as np
      6 
----> 7 from .pycompat import dask_array_type
      8 
      9 try:

/usr/lib/python3/dist-packages/xarray/core/pycompat.py in <module>
     15     import sparse
     16 
---> 17     sparse_array_type = (sparse.SparseArray,)
     18 except ImportError:  # pragma: no cover
     19     sparse_array_type = ()

AttributeError: module 'sparse' has no attribute 'SparseArray'


Cheers,

Mika


-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (650, 'testing'), (450, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.6.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages python3-xarray depends on:
ii  python3                3.8.2-3
ii  python3-numpy          1:1.17.4-5
ii  python3-pandas         0.25.3+dfsg2-2
ii  python3-pkg-resources  46.1.3-1

Versions of packages python3-xarray recommends:
ii  python3-bottleneck  1.2.1+ds1-2+b2
ii  python3-dask        2.11.0+dfsg-1
ii  python3-h5netcdf    0.8.0-1
ii  python3-netcdf4     1.5.3-1+b5
ii  python3-zarr        2.4.0+ds-1

Versions of packages python3-xarray suggests:
pn  python-xarray-doc   <none>
pn  python3-cartopy     <none>
ii  python3-matplotlib  3.2.1-1+b1
pn  python3-pydap       <none>
pn  python3-rasterio    <none>
ii  python3-scipy       1.4.1-2
ii  python3-seaborn     0.10.1-1
ii  python3-toolz       0.9.0-1.1

-- no debconf information



More information about the debian-science-maintainers mailing list