Panel | JupyterLab Setup | 'Document' object has no attribute '_hold'

Hello all,

I am new to the community and look forward to engaging, participating and learning with everyone!


I have had a really rough experience for the last few hours trying to get Panel set up in my Jupyter environment (Anaconda) for the first time.

First, I was getting hit with no interactivity in the notebook; the widgets would render fine but adjusting them did nothing to update the plots.

Then, I was having issues with nodejs plus jupyterlab_pyviz does not yet support the current version of JupyterLab (which I was able to fix by finding that the documentation is outdated relating to pyviz_comms).

I’m aware that the documentation sets out additional steps for JupyterLab but I am getting hit with this issue in both a ‘classic notebook’ as well as a notebook in JupyterLab.


Currently, I am not able to render a panel widget as I get an attribute error. I was able to do it previously before updating some of the packages. I can render ipywidgets fine in my notebook.

Error:
AttributeError: ‘Document’ object has no attribute ‘_hold’

The issue appears when I’m trying to display the widget in the notebook.

import panel as pn
import datetime as dt
pn.extension()

date_range_slider = pn.widgets.DateRangeSlider(
name=‘Date Range Slider’,
start=dt.datetime(2017, 1, 1), end=dt.datetime(2019, 1, 1),
value=(dt.datetime(2017, 1, 1), dt.datetime(2018, 1, 10))
)

date_range_slider


Here are the packages in the notebook. I’ve updated using ```conda update --all`` as well as updating the individual packages.

panel==0.12.7
pandas==1.2.4
ipywidgets==7.6.3
hvplot==0.7.3
holoviews==1.14.8


Thanks for any guidance to get up and running!

2 Likes

Try updating bokeh to version 2.4.2 to fix the AttributeError.

The default channel, which conda uses, is not necessarily up-to-date with the latest package releases.

A suggestion from me is to use the conda-forge channel and create a new environment with something like this:

conda create -n panel_test -c conda-forge python=3.8 panel jupyterlab ipywidgets hvplot numpy pandas

Though, one of the downsides of using conda-forge is it takes a long time to solve. Therefore an alternative is to install and use mamba instead of conda. Installation of mamba is done with conda install mamba -c conda-forge and can then be used as a drop-in for the conda command above.

I hope this will help you get started.

3 Likes

Same issues here. Went through most of the install instructions under the Holoviz umbrella. My environment:

  • Windows 11 Pro, Version 21H2, Build 22000.613
  • WSL2 with Pengwin Enterprise Linux 7 (basically CentOS 7)
  • Miniconda 4.12.0
  • VS Code 1.66.2

To get JupyterLab or VS Code interactive notebook running:

  1. Make sure sqlite installed on the system
  2. Uninstall/reinstall Python3 with ./configure --enable-loadable-sqlite-extensions --enable-optimizations
  3. @Hoxbro’s command conda create -n panel_test -c conda-forge python=3.8 panel jupyterlab ipywidgets hvplot numpy pandas
  4. conda install -c bokeh jupyter_bokeh.
  5. Configure VS Code setting: "jupyter.widgetScriptSources": [ "jsdelivr.com", "unpkg.com"]
  6. Enable VS Code extension with pn.extension(comms='vscode')

Also installed nodejs 16.14.2 on system in a previous attempt - not sure if it matters. VS Code is showing Node.js 16.13.0.

Any recommendations from the Holoviz Pros regarding an effective dev setup (vs code, jupyterlab, etc.) would be appreciated.
Good Luck!

Just to be sure, are you trying to run Panel in Jupyter Lab or in the interactive notebook offered by VS Code?

Good question. I’ve conflated the two. JupyterLab runs well. VS Code’s interactive notebook runs the code but has issues. The widgets display and move but there is no interaction with the plots, e.g., the Clifford Interact or Dynamic Timeseries Image Analysis demos.

An issue with JupyterLab: when attemting View -> Render Notebook with Panel, the render window shows:
500: Internal Server Error
due to a bad path:
ValueError: Path for Bokeh server application does not exist: /home/user/src/condamnation/~/src/condamnation/co2_dashboard/Untitled.ipynb

I assume this is WSL related. Do we know where JupyterLab is getting the path?

I should have fixed the path problem you are describing here.

Try to update Panel to 0.13.0. As it is just released you should use the pyviz channel if installing with conda.

Correction: VS Code notebook is working fine. I didn’t follow my own advice and enable pn.extension(comms='vscode').

I upgraded to panel 0.13.0 using conda install -c pyviz panel. I am getting another error from the JupyterLab render window:

ServerApp - ERROR - Uncaught exception GET /panel-preview/render/Untitled.ipynb (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/panel-preview/render/Untitled.ipynb', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/home/user/miniconda3/envs/panel_test/lib/python3.8/site-packages/tornado/web.py", line 1704, in _execute
    result = await result
  File "/home/user/miniconda3/envs/panel_test/lib/python3.8/site-packages/panel/io/jupyter_server_extension.py", line 116, in get
    page = server_html_page_for_session(
  File "/home/user/miniconda3/envs/panel_test/lib/python3.8/site-packages/bokeh/embed/server.py", line 255, in server_html_page_for_session
    bundle = bundle_for_objs_and_resources(None, resources)
  File "/home/user/miniconda3/envs/panel_test/lib/python3.8/site-packages/bokeh/embed/bundle.py", line 211, in bundle_for_objs_and_resources
    js_files.extend(js_resources.js_files)
  File "/home/user/miniconda3/envs/panel_test/lib/python3.8/site-packages/panel/io/resources.py", line 299, in js_files
    dist_dir = self.dist_dir
  File "/home/user/miniconda3/envs/panel_test/lib/python3.8/site-packages/panel/io/resources.py", line 259, in dist_dir
    if self.absolute:
AttributeError: 'Resources' object has no attribute 'absolute'

@skytaker Thanks for reporting that. Sadly that does indeed look like a bug that will have to be patched in a 0.13.1 asap.

Fixed here, will try to get a new release out Monday.

2 Likes

I installed the master with your fix:

# packages in environment at /home/user/miniconda3/envs/panel_test:
#
# Name                    Version                   Build  Channel
panel                     0.13.0.post1+g5b932fac          pypi_0    pypi

No obvious errors but the render tab is blank. There is an error and a warning in debug output (below) but these were also present before opening the render view.

...
[D 2022-04-15 15:22:38.683 ServerApp] activity on f9519b53-ed52-4c5e-92f7-55a83192310f: status (busy)
[D 2022-04-15 15:22:38.685 ServerApp] activity on f9519b53-ed52-4c5e-92f7-55a83192310f: status (busy)
[IPKernelApp] ERROR | No such comm target registered: jupyter.widget.control
[D 2022-04-15 15:22:38.689 ServerApp] activity on f9519b53-ed52-4c5e-92f7-55a83192310f: status (idle)
[IPKernelApp] WARNING | No such comm: 6d951a2c-6506-4b0d-b699-758eb76abd48
[D 2022-04-15 15:22:38.692 ServerApp] activity on f9519b53-ed52-4c5e-92f7-55a83192310f: status (busy)
[D 2022-04-15 15:22:38.695 ServerApp] activity on f9519b53-ed52-4c5e-92f7-55a83192310f: comm_close
[D 2022-04-15 15:22:38.698 ServerApp] activity on f9519b53-ed52-4c5e-92f7-55a83192310f: status (idle)
...
[I 2022-04-15 15:23:01.908 ServerApp] Saving file at /Untitled.ipynb
[D 2022-04-15 15:46:53.788 ServerApp] Saving /home/user/src/condamnation/co2_dashboard/Untitled.ipynb
[D 2022-04-15 15:46:53.925 ServerApp] 200 PUT /api/contents/Untitled.ipynb?1650055614321 (127.0.0.1) 326.67ms
[D 2022-04-15 15:46:53.933 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:46:53.934 ServerApp] 200 GET /api/contents/Untitled.ipynb/checkpoints?1650055614737 (127.0.0.1) 1.45ms
[D 2022-04-15 15:46:53.935 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:46:53.937 ServerApp] 200 GET /api/contents/Untitled.ipynb?content=0&1650055614737 (127.0.0.1) 1.90ms
[D 2022-04-15 15:46:53.942 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:46:53.944 ServerApp] 200 GET /api/contents?content=1&1650055614747 (127.0.0.1) 1.88ms
[D 2022-04-15 15:46:53.961 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:46:53.962 ServerApp] 200 GET /api/contents/Untitled.ipynb/checkpoints?1650055614761 (127.0.0.1) 1.48ms
[D 2022-04-15 15:46:54.008 ServerApp] Applying preprocessor: TagRemovePreprocessor
[D 2022-04-15 15:46:54.023 ServerApp] Applying preprocessor: RegexRemovePreprocessor
[D 2022-04-15 15:46:54.067 ServerApp] Applying preprocessor: coalesce_streams
[D 2022-04-15 15:46:54.165 ServerApp] Attempting to load template index.py.j2
[D 2022-04-15 15:46:54.165 ServerApp]     template_paths: /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/python:/usr/local/share/jupyter/nbconvert/templates/python:/home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/base:/usr/local/share/jupyter/nbconvert/templates/base:/home/user/.local/share/jupyter:/home/user/.local/share/jupyter/nbconvert/templates:/home/user/.local/share/jupyter/nbconvert/templates/compatibility:/home/user/miniconda3/envs/panel_test/share/jupyter:/home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates:/home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/compatibility:/usr/local/share/jupyter:/usr/local/share/jupyter/nbconvert/templates:/usr/local/share/jupyter/nbconvert/templates/compatibility:/usr/share/jupyter:/usr/share/jupyter/nbconvert/templates:/usr/share/jupyter/nbconvert/templates/compatibility:/home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates:/usr/local/share/jupyter/nbconvert/templates
[D 2022-04-15 15:46:54.165 ServerApp] Template paths:
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/python
        /usr/local/share/jupyter/nbconvert/templates/python
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/base
        /usr/local/share/jupyter/nbconvert/templates/base
        /home/user/.local/share/jupyter
        /home/user/.local/share/jupyter/nbconvert/templates
        /home/user/.local/share/jupyter/nbconvert/templates/compatibility
        /home/user/miniconda3/envs/panel_test/share/jupyter
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/compatibility
        /usr/local/share/jupyter
        /usr/local/share/jupyter/nbconvert/templates
        /usr/local/share/jupyter/nbconvert/templates/compatibility
        /usr/share/jupyter
        /usr/share/jupyter/nbconvert/templates
        /usr/share/jupyter/nbconvert/templates/compatibility
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates
        /usr/local/share/jupyter/nbconvert/templates
[D 2022-04-15 15:46:54.225 ServerApp] Applying preprocessor: TagRemovePreprocessor
[D 2022-04-15 15:46:54.239 ServerApp] Applying preprocessor: RegexRemovePreprocessor
[D 2022-04-15 15:46:54.282 ServerApp] Applying preprocessor: coalesce_streams
[D 2022-04-15 15:46:54.376 ServerApp] Attempting to load template index.py.j2
[D 2022-04-15 15:46:54.376 ServerApp]     template_paths: /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/python:/usr/local/share/jupyter/nbconvert/templates/python:/home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/base:/usr/local/share/jupyter/nbconvert/templates/base:/home/user/.local/share/jupyter:/home/user/.local/share/jupyter/nbconvert/templates:/home/user/.local/share/jupyter/nbconvert/templates/compatibility:/home/user/miniconda3/envs/panel_test/share/jupyter:/home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates:/home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/compatibility:/usr/local/share/jupyter:/usr/local/share/jupyter/nbconvert/templates:/usr/local/share/jupyter/nbconvert/templates/compatibility:/usr/share/jupyter:/usr/share/jupyter/nbconvert/templates:/usr/share/jupyter/nbconvert/templates/compatibility:/home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates:/usr/local/share/jupyter/nbconvert/templates
[D 2022-04-15 15:46:54.376 ServerApp] Template paths:
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/python
        /usr/local/share/jupyter/nbconvert/templates/python
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/base
        /usr/local/share/jupyter/nbconvert/templates/base
        /home/user/.local/share/jupyter
        /home/user/.local/share/jupyter/nbconvert/templates
        /home/user/.local/share/jupyter/nbconvert/templates/compatibility
        /home/user/miniconda3/envs/panel_test/share/jupyter
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates/compatibility
        /usr/local/share/jupyter
        /usr/local/share/jupyter/nbconvert/templates
        /usr/local/share/jupyter/nbconvert/templates/compatibility
        /usr/share/jupyter
        /usr/share/jupyter/nbconvert/templates
        /usr/share/jupyter/nbconvert/templates/compatibility
        /home/user/miniconda3/envs/panel_test/share/jupyter/nbconvert/templates
        /usr/local/share/jupyter/nbconvert/templates
[D 2022-04-15 15:46:58.296 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:46:58.297 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:46:58.298 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:46:58.298 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:46:58.299 ServerApp] 200 GET /api/terminals?1650055614781 (127.0.0.1) 3.53ms
[D 2022-04-15 15:46:58.300 LabApp] 204 PUT /lab/api/workspaces/default?1650055615304 (127.0.0.1) 3.45ms
[D 2022-04-15 15:46:58.301 ServerApp] 200 GET /api/kernels?1650055618190 (127.0.0.1) 3.68ms
[D 2022-04-15 15:46:58.302 ServerApp] 200 GET /api/sessions?1650055618191 (127.0.0.1) 4.13ms
[D 2022-04-15 15:47:04.012 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:47:04.013 ServerApp] 200 GET /api/contents?content=1&1650055624815 (127.0.0.1) 1.25ms
[D 2022-04-15 15:47:08.322 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:47:08.323 ServerApp] 200 GET /api/terminals?1650055629125 (127.0.0.1) 1.17ms
[D 2022-04-15 15:47:08.369 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:47:08.370 ServerApp] 200 GET /api/kernels?1650055629172 (127.0.0.1) 1.24ms
[D 2022-04-15 15:47:08.385 ServerApp] Accepting token-authenticated connection from 127.0.0.1
[D 2022-04-15 15:47:08.385 ServerApp] 200 GET /api/sessions?1650055629187 (127.0.0.1) 1.06ms
...

The fix works fine on my computer (Linux). Installed with pip install panel --pre or conda install -c pyviz/label/dev "panel=0.13.1a1" -c conda-forge

Just to be sure you have made your pane/widget servable?

import panel as pn
pn.extension()
pn.panel("# Test").servable()

1 Like

Render window is working properly after the install command:
conda install -c pyviz/label/dev "panel=0.13.1a1" -c conda-forge

Complete JupyterLab install for conda env:

> conda create -n panel_test -c conda-forge python=3.8 panel jupyterlab ipywidgets hvplot numpy pandas
> conda install -n panel_test -c bokeh jupyter_bokeh
> conda install -n panel_test -c pyviz/label/dev "panel=0.13.1a1" -c conda-forge

Thanks!

2 Likes