Panel in Jupyterlab throws an error message

I can’t work out what I’m doing wrong here.

import panel as pn


This thows the following error:

Traceback (most recent call last):
File “/Users/rob/miniconda3/envs/panel/lib/python3.7/site-packages/pyviz_comms/”, line 325, in _handle_msg
File “/Users/rob/miniconda3/envs/panel/lib/python3.7/site-packages/panel/”, line 272, in _on_msg
AttributeError: ‘NoneType’ object has no attribute ‘id’

It seems to do it on every/any panel app I try to run.

I tried with a fresh conda environment (via conda-forge channel) and the same happens.

Any ideas?

I usually avoid rendering panel templates directly within a notebook, notebooks are not designed to render this sort of thing (pretty much a website). I wasn’t aware of this error though.

What you could try is add .servable() to your template object and serve it out of the notebook by running this from the command line: panel serve yournotebook.ipynb --show.

A trick in the notebook to avoid rendering an object is to add ; after the command to suppress the output, it’s actually an IPython’s trick: obj.servable();.

Thanks. Does that mean it won’t render in the notebook and I shouldn’t expect it to? is the issue trying to render the template within the notebook?

What I actually wanted to do was to render it in the jupyterlab sidecar area eventually.

Well I don’t know if the error you get is expected, I just usually don’t expect a template to render well in a notebook (I tried today with the Material template and it looked just messed up). If you could try to launch your app from the command line (with adding .servable() to the object you want to serve), that would allow you to check if it’s running correctly. In a notebook you could alternatively add .show() to the object you want to serve and run the cell.

Thanks. It doesn’t seem to render by running the notebook either with .servable. The same code runs fine from a .py script.

However, it does seem to work with .show in the notebook (and opens app in browser window).