Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panelite HoloViews.ipynb: No such file or directory: '/lib/python3.10/site-packages/bokeh/server/static/js/bokeh.min.js' #4393

Closed
MarcSkovMadsen opened this issue Feb 4, 2023 · 7 comments · Fixed by holoviz/holoviews#5683
Labels

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Feb 4, 2023

Panelite==0.14.3

I am trying to improve the user experience of Panelite in #4388. When trying to run the HoloViews.ipynb reference notebook in Panelite I get the exception below.

image

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[5], line 2
      1 import pandas as pd
----> 2 import hvplot.pandas
      3 import holoviews.plotting.bokeh
      5 def sine(frequency=1.0, amplitude=1.0, function='sin'):

File /lib/python3.10/site-packages/hvplot/pandas.py:25
     21     setattr(pd.Series, interactive, interactive_prop)
     23     post_patch(extension, logo)
---> 25 patch()

File /lib/python3.10/site-packages/hvplot/pandas.py:23, in patch(name, interactive, extension, logo)
     20 setattr(pd.DataFrame, interactive, interactive_prop)
     21 setattr(pd.Series, interactive, interactive_prop)
---> 23 post_patch(extension, logo)

File /lib/python3.10/site-packages/hvplot/__init__.py:166, in post_patch(extension, logo)
    164 def post_patch(extension='bokeh', logo=False):
    165     if extension and not getattr(_hv.extension, '_loaded', False):
--> 166         hvplot_extension(extension, logo=logo)

File /lib/python3.10/site-packages/pyviz_comms/__init__.py:64, in extension.__new__(cls, *args, **kwargs)
     62 except Exception:
     63     pass
---> 64 return param.ParameterizedFunction.__new__(cls, *args, **kwargs)

File /lib/python3.10/site-packages/param/parameterized.py:3658, in ParameterizedFunction.__new__(class_, *args, **params)
   3656 inst = class_.instance()
   3657 inst.param._set_name(class_.__name__)
-> 3658 return inst.__call__(*args,**params)

File /lib/python3.10/site-packages/hvplot/utilities.py:45, in hvplot_extension.__call__(self, *args, **params)
     40 def __call__(self, *args, **params):
     41     # importing e.g. hvplot.pandas always loads the bokeh extension.
     42     # so hvplot.extension('matplotlib', compatibility='bokeh') doesn't
     43     # require the user or the code to explicitely load bokeh.
     44     compatibility = params.pop('compatibility', None)
---> 45     super().__call__(*args, **params)
     46     backend = _hv.Store.current_backend
     47     if compatibility in ['matplotlib', 'plotly'] and backend != compatibility:

File /lib/python3.10/site-packages/holoviews/ipython/__init__.py:187, in notebook_extension.__call__(self, *args, **params)
    185     Store.renderers[r].load_nb(inline=p.inline)
    186 if not same_cell_execution:
--> 187     Renderer.load_nb(inline=p.inline)
    189 if hasattr(ip, 'kernel') and not loaded:
    190     Renderer.comm_manager.get_client_comm(notebook_extension._process_comm_msg,
    191                                           "hv-extension-comm")

File /lib/python3.10/site-packages/holoviews/plotting/renderer.py:643, in Renderer.load_nb(cls, inline)
    637 @classmethod
    638 def load_nb(cls, inline=True):
    639     """
    640     Loads any resources required for display of plots
    641     in the Jupyter notebook
    642     """
--> 643     load_notebook(inline)
    644     with param.logging_level('ERROR'):
    645         try:

File /lib/python3.10/site-packages/panel/io/notebook.py:251, in load_notebook(inline, load_timeout)
    249 resources = Resources.from_bokeh(resources)
    250 try:
--> 251     bundle = bundle_resources(None, resources)
    252     bundle = Bundle.from_bokeh(bundle)
    253     configs, requirements, exports, skip_imports = require_components()

File /lib/python3.10/site-packages/panel/io/resources.py:227, in bundle_resources(roots, resources)
    224     if not use_mathjax and "bokeh-mathjax" in js_resources.js_components:
    225         js_resources.js_components.remove("bokeh-mathjax")
--> 227     js_files.extend(js_resources.js_files)
    228     js_raw.extend(js_resources.js_raw)
    230 css_files.extend(css_resources.css_files)

File /lib/python3.10/site-packages/panel/io/resources.py:348, in Resources.js_files(self)
    344 @property
    345 def js_files(self):
    346     from ..config import config
--> 348     files = super(Resources, self).js_files
    349     self.extra_resources(files, '__javascript__')
    351     js_files = self.adjust_paths(files)

File /lib/python3.10/site-packages/bokeh/resources.py:481, in JSResources.js_files(self)
    479 @property
    480 def js_files(self) -> List[str]:
--> 481     files, _, _ = self._resolve("js")
    482     external_resources = self._collect_external_resources("__javascript__")
    483     return external_resources + files

File /lib/python3.10/site-packages/bokeh/resources.py:397, in BaseResources._resolve(self, kind)
    394 hashes = {}
    396 if self.mode == "inline":
--> 397     raw = [self._inline(path) for path in paths]
    398 elif self.mode == "relative":
    399     root_dir = self.root_dir or self._default_root_dir

File /lib/python3.10/site-packages/bokeh/resources.py:397, in <listcomp>(.0)
    394 hashes = {}
    396 if self.mode == "inline":
--> 397     raw = [self._inline(path) for path in paths]
    398 elif self.mode == "relative":
    399     root_dir = self.root_dir or self._default_root_dir

File /lib/python3.10/site-packages/bokeh/resources.py:418, in BaseResources._inline(path)
    416 filename = basename(path)
    417 begin = f"/* BEGIN {filename} */"
--> 418 with open(path, "rb") as f:
    419     middle = f.read().decode("utf-8")
    420 end = f"/* END {filename} */"

FileNotFoundError: [Errno 44] No such file or directory: '/lib/python3.10/site-packages/bokeh/server/static/js/bokeh.min.js'

I don't know if this is a Bokeh issue or due to Panel using a special, scaled down version of Bokeh?

@MarcSkovMadsen
Copy link
Collaborator Author

Another example is the reference/panes/Param.ipynb notebook

image

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Feb 7, 2023

Other example notebook that fails due to this error are

  • gallery/apis/stocks_hvplot.ipynb
  • gallery/dynamic/dynamic_timeseries_image_analysis.ipynb
  • gallery/layout/dynamic_tabs.ipynb
  • gallery/layout/plot_with_columns.ipynb
  • gallery/param/reactive_plots.ipynb
  • gallery/simple/defer_data_load.ipynb

@MarcSkovMadsen
Copy link
Collaborator Author

The problem is really with hvplot

@MarcSkovMadsen
Copy link
Collaborator Author

I can see that if I rerun the failing cell of gallery/param/reactive_plots.ipynb where hvplot is imported it does not fail the second time and the notebook works?! (Except that it also needs to rerun the component cell twice to work - same as #4416)

hvplot-import-twice.mp4

@MarcSkovMadsen
Copy link
Collaborator Author

I see the issue in gallery/streaming/hardware_automation.ipynb too. And here we are using HoloViews. Its actually when we run hv.extension("bokeh") this fails.

image

@MarcSkovMadsen
Copy link
Collaborator Author

This is the biggest issue to solve for Panelite. Affects many, many notebooks. And Panel in Panelite not working with hvplot/ HoloViews is not great.

@MarcSkovMadsen
Copy link
Collaborator Author

I can see that if I run pn.extension before hv.extension then it does not fail. But it does if I do it the other way around.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant