TypeError when running Holoviz with bokeh in Azure ML Studio

When I fire up JupyterLab on a compute instance in Azure ML Studio and try to run a Holoviz notebook with bokeh on a holoviz-enabled kernel, I’m getting a type error:

import xarray as xr
import hvplot.xarray
da = xr.tutorial.open_dataset('air_temperature')
da.hvplot(x='lon', y='lat', geo=True)

produces:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 da.hvplot(x='lon', y='lat', geo=True)

File /anaconda/envs/pangeo/lib/python3.11/site-packages/hvplot/plotting/core.py:95, in hvPlotBase.__call__(self, x, y, kind, **kwds)
     92         plot = self._get_converter(x, y, kind, **kwds)(kind, x, y)
     93         return pn.panel(plot, **panel_dict)
---> 95 return self._get_converter(x, y, kind, **kwds)(kind, x, y)

File /anaconda/envs/pangeo/lib/python3.11/site-packages/hvplot/plotting/core.py:102, in hvPlotBase._get_converter(self, x, y, kind, **kwds)
    100 y = y or params.pop('y', None)
    101 kind = kind or params.pop('kind', None)
--> 102 return HoloViewsConverter(self._data, x, y, kind=kind, **params)

File /anaconda/envs/pangeo/lib/python3.11/site-packages/hvplot/converter.py:620, in HoloViewsConverter.__init__(self, data, x, y, kind, by, use_index, group_label, value_label, backlog, persist, use_dask, crs, fields, groupby, dynamic, grid, legend, rot, title, xlim, ylim, clim, robust, symmetric, logx, logy, loglog, hover, subplots, label, invert, stacked, colorbar, datashade, rasterize, downsample, resample_when, row, col, debug, framewise, aggregator, projection, global_extent, geo, precompute, flip_xaxis, flip_yaxis, dynspread, hover_cols, x_sampling, y_sampling, project, tools, attr_labels, coastline, tiles, tiles_opts, sort_date, check_symmetric_max, transforms, stream, cnorm, features, rescale_discrete_levels, autorange, **kwds)
    618 self.dynamic = dynamic
    619 self.geo = any([geo, crs, global_extent, projection, project, coastline, features])
--> 620 self.crs = self._process_crs(data, crs) if self.geo else None
    621 self.output_projection = self.crs
    622 self.project = project

File /anaconda/envs/pangeo/lib/python3.11/site-packages/hvplot/converter.py:953, in HoloViewsConverter._process_crs(self, data, crs)
    950     _crs = crs
    952 try:
--> 953     return process_crs(_crs)
    954 except ValueError as e:
    955     # only raise error if crs was specified in kwargs
    956     if crs:

File /anaconda/envs/pangeo/lib/python3.11/site-packages/hvplot/util.py:275, in process_crs(crs)
    273     missing.append('cartopy')
    274 try:
--> 275     import geoviews as gv  # noqa
    276 except ImportError:
    277     missing.append('geoviews')

File /anaconda/envs/pangeo/lib/python3.11/site-packages/geoviews/__init__.py:18
     16 from ._warnings import GeoviewsDeprecationWarning, GeoviewsUserWarning  # noqa: F401
     17 from . import data                                  # noqa (API import)
---> 18 from . import plotting                              # noqa (API import)
     19 from . import feature                               # noqa (API import)
     20 from . import tile_sources                          # noqa (API import)

File /anaconda/envs/pangeo/lib/python3.11/site-packages/geoviews/plotting/__init__.py:19
     17 backends = Store.loaded_backends()
     18 if 'bokeh' in backends:
---> 19     _load_bokeh()
     20 if 'matplotlib' in backends:
     21     _load_mpl()

File /anaconda/envs/pangeo/lib/python3.11/site-packages/geoviews/plotting/__init__.py:10, in _load_bokeh()
      9 def _load_bokeh():
---> 10     from . import bokeh

File /anaconda/envs/pangeo/lib/python3.11/site-packages/geoviews/plotting/bokeh/__init__.py:23
     17 from holoviews.plotting.bokeh.raster import RasterPlot, RGBPlot, QuadMeshPlot
     18 from ...element import (
     19     WMTS, Points, Polygons, Path, Contours, Shape, Image, ImageStack, Feature,
     20     Text, RGB, Nodes, EdgePaths, Graph, TriMesh, QuadMesh, VectorField,
     21     Labels, HexTiles, LineContours, FilledContours, Rectangles, Segments
     22 )
---> 23 from ...operation import (
     24     project_image, project_points, project_path, project_graph,
     25     project_quadmesh, project_geom, project_vectorfield
     26 )
     27 from ...tile_sources import _ATTRIBUTIONS
     28 from ...util import poly_types, line_types

File /anaconda/envs/pangeo/lib/python3.11/site-packages/geoviews/operation/__init__.py:15
     13 geo_ops = [contours, bivariate_kde]
     14 try:
---> 15     from holoviews.operation.datashader import shade, stack, dynspread
     16     from holoviews.operation.resample import ResampleOperation2D
     17     geo_ops += [ResampleOperation2D, shade, stack, dynspread]

File /anaconda/envs/pangeo/lib/python3.11/site-packages/holoviews/operation/datashader.py:5
      2 from collections.abc import Callable, Iterable
      3 from functools import partial
----> 5 import dask.dataframe as dd
      6 import datashader as ds
      7 import datashader.reductions as rd

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/__init__.py:6
      4 import dask.dataframe._pyarrow_compat
      5 from dask.base import compute
----> 6 from dask.dataframe import backends, dispatch, rolling
      7 from dask.dataframe.core import (
      8     DataFrame,
      9     Index,
   (...)
     15     to_timedelta,
     16 )
     17 from dask.dataframe.groupby import Aggregation

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/backends.py:15
     13 from dask.backends import CreationDispatch, DaskBackendEntrypoint
     14 from dask.dataframe._compat import is_any_real_numeric_dtype
---> 15 from dask.dataframe.core import DataFrame, Index, Scalar, Series, _Frame
     16 from dask.dataframe.dispatch import (
     17     categorical_dtype_dispatch,
     18     concat,
   (...)
     34     union_categoricals_dispatch,
     35 )
     36 from dask.dataframe.extensions import make_array_nonempty, make_scalar

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/core.py:36
     34 from dask.blockwise import Blockwise, BlockwiseDep, BlockwiseDepDict, blockwise
     35 from dask.context import globalmethod
---> 36 from dask.dataframe import methods
     37 from dask.dataframe._compat import (
     38     PANDAS_GE_140,
     39     PANDAS_GE_150,
   (...)
     47     is_string_dtype,
     48 )
     49 from dask.dataframe.accessor import CachedAccessor, DatetimeAccessor, StringAccessor

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/methods.py:33
     21 #  preserve compatibility while moving dispatch objects
     22 from dask.dataframe.dispatch import (  # noqa: F401
     23     concat,
     24     concat_dispatch,
   (...)
     31     union_categoricals,
     32 )
---> 33 from dask.dataframe.utils import is_dataframe_like, is_index_like, is_series_like
     35 # cuDF may try to import old dispatch functions
     36 hash_df = hash_object_dispatch

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/utils.py:20
     18 from dask.base import get_scheduler, is_dask_collection
     19 from dask.core import get_deps
---> 20 from dask.dataframe import (  # noqa: F401 register pandas extension types
     21     _dtypes,
     22     methods,
     23 )
     24 from dask.dataframe._compat import PANDAS_GE_150, tm  # noqa: F401
     25 from dask.dataframe.dispatch import (  # noqa : F401
     26     make_meta,
     27     make_meta_obj,
     28     meta_nonempty,
     29 )

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/_dtypes.py:9
      6 import pandas as pd
      8 from dask.dataframe._compat import PANDAS_GE_150
----> 9 from dask.dataframe.extensions import make_array_nonempty, make_scalar
     12 @make_array_nonempty.register(pd.DatetimeTZDtype)
     13 def _(dtype):
     14     return pd.array([pd.Timestamp(1), pd.NaT], dtype=dtype)

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/extensions.py:8
      1 """
      2 Support for pandas ExtensionArray in dask.dataframe.
      3 
      4 See :ref:`extensionarrays` for more.
      5 """
      6 from __future__ import annotations
----> 8 from dask.dataframe.accessor import (
      9     register_dataframe_accessor,
     10     register_index_accessor,
     11     register_series_accessor,
     12 )
     13 from dask.utils import Dispatch
     15 make_array_nonempty = Dispatch("make_array_nonempty")

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/accessor.py:126
    113         token = f"{self._accessor_name}-{attr}"
    114         return self._series.map_partitions(
    115             self._delegate_method,
    116             self._accessor_name,
   (...)
    122             token=token,
    123         )
--> 126 class DatetimeAccessor(Accessor):
    127     """Accessor object for datetimelike properties of the Series values.
    128 
    129     Examples
   (...)
    132     >>> s.dt.microsecond  # doctest: +SKIP
    133     """
    135     _accessor_name = "dt"

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/accessor.py:81, in Accessor.__init_subclass__(cls, **kwargs)
     79 attr, min_version = item if isinstance(item, tuple) else (item, None)
     80 if not hasattr(cls, attr):
---> 81     _bind_property(cls, pd_cls, attr, min_version)

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/dataframe/accessor.py:35, in _bind_property(cls, pd_cls, attr, min_version)
     33 except Exception:
     34     pass
---> 35 setattr(cls, attr, property(derived_from(pd_cls, version=min_version)(func)))

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/utils.py:851, in derived_from.<locals>.wrapper(method)
    849 try:
    850     extra = getattr(method, "__doc__", None) or ""
--> 851     method.__doc__ = _derived_from(
    852         original_klass,
    853         method,
    854         ua_args=ua_args,
    855         extra=extra,
    856         skipblocks=skipblocks,
    857         inconsistencies=inconsistencies,
    858     )
    859     return method
    861 except AttributeError:

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/utils.py:804, in _derived_from(cls, method, ua_args, extra, skipblocks, inconsistencies)
    802 # Mark unsupported arguments
    803 try:
--> 804     method_args = get_named_args(method)
    805     original_args = get_named_args(original_method)
    806     not_supported = [m for m in original_args if m not in method_args]

File /anaconda/envs/pangeo/lib/python3.11/site-packages/dask/utils.py:570, in get_named_args(func)
    568 def get_named_args(func) -> list[str]:
    569     """Get all non ``*args/**kwargs`` arguments for a function"""
--> 570     s = inspect.signature(func)
    571     return [
    572         n
    573         for n, p in s.parameters.items()
    574         if p.kind in [p.POSITIONAL_OR_KEYWORD, p.POSITIONAL_ONLY, p.KEYWORD_ONLY]
    575     ]

File /anaconda/envs/pangeo/lib/python3.11/inspect.py:3263, in signature(obj, follow_wrapped, globals, locals, eval_str)
   3261 def signature(obj, *, follow_wrapped=True, globals=None, locals=None, eval_str=False):
   3262     """Get a signature object for the passed callable."""
-> 3263     return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
   3264                                    globals=globals, locals=locals, eval_str=eval_str)

File /anaconda/envs/pangeo/lib/python3.11/inspect.py:3011, in Signature.from_callable(cls, obj, follow_wrapped, globals, locals, eval_str)
   3007 @classmethod
   3008 def from_callable(cls, obj, *,
   3009                   follow_wrapped=True, globals=None, locals=None, eval_str=False):
   3010     """Constructs Signature for the given callable object."""
-> 3011     return _signature_from_callable(obj, sigcls=cls,
   3012                                     follow_wrapper_chains=follow_wrapped,
   3013                                     globals=globals, locals=locals, eval_str=eval_str)

File /anaconda/envs/pangeo/lib/python3.11/inspect.py:2599, in _signature_from_callable(obj, follow_wrapper_chains, skip_bound_arg, globals, locals, eval_str, sigcls)
   2597     call = getattr_static(type(obj), '__call__', None)
   2598     if call is not None:
-> 2599         call = _descriptor_get(call, obj)
   2600         return _get_signature_of(call)
   2602 raise ValueError('callable {!r} is not supported by signature'.format(obj))

File /anaconda/envs/pangeo/lib/python3.11/inspect.py:2432, in _descriptor_get(descriptor, obj)
   2430 if get is _sentinel:
   2431     return descriptor
-> 2432 return get(descriptor, obj, type(obj))

TypeError: descriptor '__call__' for 'type' objects doesn't apply to a 'property' object
​```
How might I got about fixing this problem?

Hi @rsignell,

It’s an issue with Dask being incompatible with some specific new versions of Python, see more context in Fix ``dask.dataframe`` import error for Python 3.11.9 by rjzamora · Pull Request #11035 · dask/dask · GitHub. Using a newer version of Dask, or older version of Python, should get you going.

Wow, thanks for the super speedy response @maximlt ! I would not have figured that out! When I googled the error, I saw some issues with dask mentioned but I ignored them, thinking that they were not relevant to the holoviz issues I was having. :upside_down_face:

It turned out although I had just created my custom env, and it had the latest holoviz packages, as you suspected, another package was pinning an older version of dask (inappropriately), and forcing an install of dask>=2024.6.2 solved the problem!

1 Like