Nothing displaying in Jupyter

I tried following the docs but cannot get anything to display in Jupyter; I just get an empty output. This is the code I am trying:

%matplotlib inline
import pandas as pd
import panel as pn
pn.extension()
import panel.widgets as pnw

window = pnw.IntSlider(name=‘window’, value=10, start=1, end=60)

@pn.depends(window)
def reactive_trends(window):
return pd.DataFrame([{‘a’: 1, ‘b’: 2}, {‘a’:3, ‘b’: 4}])

widgets = pn.Column(“
\n# Filter”, window)
trends = pn.Row(reactive_trends, widgets)
trends

I assume I’m missing something obvious here?

I tried a sample notebook and have the same problem. Looking at the JS console I see complaints about BokehJS not being found, even though I have bokeh installed in my environment.

I searched around, and found a suggestion to add:

from bokeh.plotting import output_notebook, figure, show

output_notebook(hide_banner=True)

However, then I got a whole lot of errors about:

Access to script at ‘https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.0.min.js’ from origin ‘http://localhost:8888’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

It looks like this was supposed to be fixed in 0.10.4 but it seems that hasn’t been released. Then again, I tried with panel 0.11.0rc5 and had the same empty output.

1 Like

Try using panel 0.10.3 and bokeh 2.2.3.

You might also need to clear the notebook output, save, close the browser, reopen and hard refresh to make it use those versions.

A Panel released 0.11 should be arriving any day now.

I installed those, and shut down and restarted Jupyter, and now I get:

AttributeError: module 'panel' has no attribute 'extension'

and likewise for interact.

Note: I am using pip, not conda.

It seems like if I use .show() then things work, so that will unblock me for now.

1 Like

You would need to provide more information in the form of a minimum, reproducible example to allow further investigation. And add in screen shots as well.

Those pip messages are weird and may have something to do with it. Something very weird is going on, because I have two notebooks open from the same instance of Jupyter, and the one is doing this, and the other one is working (as long as I use show()). Both show the same versions of panel and bokeh (plus that weird error), but they are in different venvs. I wouldn’t worry too much about it as I have one working environment and this must be something screwy with the other one.

What would be useful to me would be a way to log to the browser console when using show(). I saw some ways of adding JS in callbacks but is there a more direct way? I find things work for me once and then seem to stop (e.g. if I have a dynamically updating set of options in a picker, it updates once and then never again), that logging would really help with.I tried using a static text widget but that stops updating too.

(Edit: it looks like just adding “import logging” helped here; I now see exceptions in my notebook output).

I wrote the following below, but when I was almost finished a thought occurred - do you have a panel.py file in the folder? This will take priority over the package and give this kind of error.


A better way to check the version number is proberly using pn.__version__ and bokeh.__version__. The pip command can sometimes be from another environment depending on OS/environment manager.

If you cannot do that, try to see if the panel file is located where you expect it to be with the following:

import panel as pn
import inspect

inspect.getfile(pn)

The small error from the pip commands look like something went wrong during a local panel install, maybe from a misspelling.

1 Like

I don’t have a panel.py. I managed to get things working as long as I stick to the one venv. My last struggle is trying to deploy; I added a .servable() call to the penultimate cell in my notebook, but when I run “panel serve” from the CLI and open the URL displayed by the Bokeh server I get 404s.

1 Like

Could you provide a screenshot with as much information as possible?

1 Like

Not much to see, really. Here’s the browser:

The browser is Firefox; pasting the URL in Chrome replaced the spaces with %20s but had the same result so I don’t think that’s the issue, but let me try.

Edit: and yes, it looks like the spaces were causing a problem! Yay! Thank goodness I don’t have to go learn Plotly :wink: Thanks all! Off to Dockerize.

1 Like