AttributeError: 'Document' object has no attribute '_hold'

Hi i am getting attribute error which has something to do with environment or brwoser.

Because tmy code is minimalistic and copied from the Documentation of Holoviews website.


import pandas as pd
import numpy as np
import holoviews as hv
hv.extension(‘bokeh’)

xs = np.linspace(0, np.pi*4, 40)
plot = hv.Area((xs, np.sin(xs)))
plot


Error :  


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj, include, exclude)
    968 
    969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
    971             return None
    972         else:

~\Anaconda3\lib\site-packages\holoviews\core\dimension.py in _repr_mimebundle_(self, include, exclude)
   1314         combined and returned.
   1315         """
-> 1316         return Store.render(self)
   1317 
   1318 

~\Anaconda3\lib\site-packages\holoviews\core\options.py in render(cls, obj)
   1403         data, metadata = {}, {}
   1404         for hook in hooks:
-> 1405             ret = hook(obj)
   1406             if ret is None:
   1407                 continue

~\Anaconda3\lib\site-packages\holoviews\ipython\display_hooks.py in pprint_display(obj)
    280     if not ip.display_formatter.formatters['text/plain'].pprint:
    281         return None
--> 282     return display(obj, raw_output=True)
    283 
    284 

~\Anaconda3\lib\site-packages\holoviews\ipython\display_hooks.py in display(obj, raw_output, **kwargs)
    250     elif isinstance(obj, (CompositeOverlay, ViewableElement)):
    251         with option_state(obj):
--> 252             output = element_display(obj)
    253     elif isinstance(obj, (Layout, NdLayout, AdjointLayout)):
    254         with option_state(obj):

~\Anaconda3\lib\site-packages\holoviews\ipython\display_hooks.py in wrapped(element)
    144         try:
    145             max_frames = OutputSettings.options['max_frames']
--> 146             mimebundle = fn(element, max_frames=max_frames)
    147             if mimebundle is None:
    148                 return {}, {}

~\Anaconda3\lib\site-packages\holoviews\ipython\display_hooks.py in element_display(element, max_frames)
    190         return None
    191 
--> 192     return render(element)
    193 
    194 

~\Anaconda3\lib\site-packages\holoviews\ipython\display_hooks.py in render(obj, **kwargs)
     66         renderer = renderer.instance(fig='png')
     67 
---> 68     return renderer.components(obj, **kwargs)
     69 
     70 

~\Anaconda3\lib\site-packages\holoviews\plotting\renderer.py in components(self, obj, fmt, comm, **kwargs)
    408                 doc = Document()
    409                 with config.set(embed=embed):
--> 410                     model = plot.layout._render_model(doc, comm)
    411                 if embed:
    412                     return render_model(model, comm)

~\Anaconda3\lib\site-packages\panel\viewable.py in _render_model(self, doc, comm)
    425 
    426         if config.embed:
--> 427             embed_state(self, model, doc,
    428                         json=config.embed_json,
    429                         json_prefix=config.embed_json_prefix,

~\Anaconda3\lib\site-packages\panel\io\embed.py in embed_state(panel, model, doc, max_states, max_opts, json, json_prefix, save_path, load_path, progress, states)
    303         values.append((ws, w_models, vals, getter))
    304 
--> 305     add_to_doc(model, doc, True)
    306     doc._held_events = []
    307 

~\Anaconda3\lib\site-packages\panel\io\model.py in add_to_doc(obj, doc, hold)
     60     remove_root(obj)
     61     doc.add_root(obj)
---> 62     if doc._hold is None and hold:
     63         doc.hold()
     64 

AttributeError: 'Document' object has no attribute '_hold'

:Area   [x]   (y)

I don’t see this problem so try update holoviews to the latest version 1.14.7.

Hi , I did upgrade Holowviews from 1.14.6 to 1.14.7.

I downloaded the Ipython NB from Holoviews Website and ran the example … Still i get attribute errors.

Can you try to update both panel and bokeh then?

Dear “unknow friend”

Many many thanks.

After updating the Panel and Bokeh, i got message " # All requested packages already installed." So i was not very optimistic while trying my Code.

Luckily, it worked very smoothly this time. My problem solved (99%).

One Question is have :

In one Notebook, I run the code df.hvplot(x=‘LONGITUDE’, y=‘LATITUDE’, kind=‘points’) and it produces an interactive plot. (zoombale); Works Perfectly Fine.

In another notebook, the same code produces an EMPTY, WHITE Cell as Output.
To generate a plot , i have to use the following workaround.

img = df.hvplot(x=‘LONGITUDE’, y=‘LATITUDE’, kind=‘points’)
show(hv.render(img))

Its hard to say without more information. I would properly try to clear the notebook and run the cells again. If the problem still persist I would suggest making a new topic about it with a minimal, reproducible example (MRE).

Thanks a lot for your advice. This topic can be closed for everyone’s clarity.

After Upgrading Holosview, Panel and Bokeh, my problem got resolved. Gratitude !

1 Like