"Cannot import name" error on import of geoviews

I’m a newbie to GeoViews and decided to try out the Airport Graph example notebook. However, when I try to import geoviews I get an error:

❯ python3
Python 3.11.4 (main, Jul  5 2023, 08:41:25) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import geoviews
Traceback (most recent call last):  File "<stdin>", line 1, in <module>
  File "/Users/mathomp4/installed/Core/GEOSpyD/23.5.2-0_py3.11/2023-07-17/lib/python3.11/site-packages/geoviews/__init__.py", line 13, in <module>
    from .annotators import annotate # noqa (API import)
  File "/Users/mathomp4/installed/Core/GEOSpyD/23.5.2-0_py3.11/2023-07-17/lib/python3.11/site-packages/geoviews/annotators.py", line 14, in <module>
    from .links import VertexTableLink, PointTableLink, HvRectanglesTableLink, RectanglesTableLink
  File "/Users/mathomp4/installed/Core/GEOSpyD/23.5.2-0_py3.11/2023-07-17/lib/python3.11/site-packages/geoviews/links.py", line 4, in <module>
    from holoviews.plotting.bokeh.callbacks import (
ImportError: cannot import name 'LinkCallback' from 'holoviews.plotting.bokeh.callbacks' (/Users/mathomp4/installed/Core/GEOSpyD/23.5.2-0_py3.11/2023-07-17/lib/python3.11/site-packages/holoviews/plotting/bokeh/callbacks.py)

I’m not sure what I did wrong. In my stack I have:

bokeh                     3.2.0              pyhd8ed1ab_0    conda-forge
geoviews                  1.8.2                      py_0    conda-forge
geoviews-core             1.8.2                      py_0    conda-forge
holoviews                 1.16.2             pyhd8ed1ab_0    conda-forge
panel                     1.2.0              pyhd8ed1ab_0    conda-forge

and much more.

Any ideas what I might need?

geoviews is pretty old try upgrading to 1.10.

Interesting. I just installed it today…but from conda-forge. I’ll try the pyviz channel…

It should also be available on conda-forge. It could be another dependency that drags it down.

No wait. It is Bokeh 3.2, which is not yet supported by Geoviews we will try to make a release this week, with support for it :slight_smile:

1 Like

This is interesting. So I updated my .condarc to be:

  - pyviz
  - conda-forge
  - defaults
channel_priority: strict

and then I see during install:

  + param              1.13.0  py_0             pyviz            104kB
  + pyviz_comms         0.7.6  py_0             pyviz             11kB
  + pyct-core           0.5.0  py_0             pyviz             16kB
  + panel               1.2.0  py_0             pyviz             18MB
  + pyct                0.5.0  py_0             pyviz              3kB
  + colorcet            3.0.1  py_0             pyviz              2MB
  + datashader         0.15.1  py_0             pyviz             17MB
  + holoviews          1.16.2  py_0             pyviz              3MB
  + hvplot              0.8.4  py_0             pyviz              3MB
  + geoviews-core       1.6.6  py_0             pyviz            362kB
  + mapclassify         2.5.0  pyhd8ed1ab_1     conda-forge     Cached
  + movingpandas       0.16.1  pyhd8ed1ab_0     conda-forge     Cached
  + geopandas          0.13.2  pyhd8ed1ab_1     conda-forge     Cached
  + geoviews            1.6.6  py_0             pyviz              3kB

So it installed an older version of geoviews than conda-forge? I see 1.10.0 in both the pyviz and conda-forge channels.

Try pin down “bokeh=3.1”.

Ah. Okay. I’ll try that. (Note: my full install script was not happy having the pyviz channel in there. Probably got confused later on.)

Huzzah! It works when I pin to bokeh 3.1!

My guess is it’ll probably take a few days for us to shake down this new Python stack, so I’m hoping by then we can remove the pin and be lazy :slight_smile:

Plus from what I see in the 3.2 Release Notes, some of the new bits might be useful.

1 Like

Thanks @mathomp4

Welcome to the community.

Thanks for asking for advice and keeping at it.

Also, in case anyone else hits this, you might hit my other issue. If you use movingpandas at the moment you need to pin hvplot to 0.8.3. :slight_smile: