jupyter-book
jupyter-book copied to clipboard
Plotly + pyppeteer [Intermittent failure] when using jb build ... --builder pdfhtml
I've been using Jupyter book for a while and had no issues, until I started incorporating Plotly visualisations (given their interactivity).
- The specific problem occurs when converting the book from html to PDF.
- NB I have addressed the common issue of enabling Javascript (as documented in other issues) - so that is taken care of
My Python notebook has a number of cells, several of which are producing graphs in loops - e.g. 10 ~ 20 graphs of different plots. These outputs are driven by data configuration, rather than code, i.e. the list of required graphs are configured as a data frame, which is consumed in a loop to generate multiple charts from a relatively small (separate) dataset..
-
Whilst investigating the issue, I was paring down my notebook to a separate "test case" notebook - and I discovered that reducing the number of Plotly outputs - caused it to work OK. i.e. rather than generating 10 - 20 graphs say (in a loop) this was reduced to say 3 - 4 in that loop, it started working without any other changes.
-
In fact, the same notebook, with the same number of graphs to be generated, could randomly fail or succeed. Therefore this does not appear to be a coding issue per se (on my part), given that it works intermittently.
The error message seems to point the finger at pyppeteer - however there doesn't appear to be any settings I can adjust to try to overcome this...
Error Message Finished generating HTML for book... Converting book HTML into PDF... Traceback (most recent call last): File "c:\programdata\anaconda3\lib\site-packages\pyppeteer\execution_context.py", line 99, in evaluateHandle _obj = await self._client.send('Runtime.callFunctionOn', { pyppeteer.errors.NetworkError: Protocol error (Runtime.callFunctionOn): Cannot find context with specified id
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\programdata\anaconda3\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\jb.exe_main.py", line 7, in
Environment
Jupyter Book : 0.12.3
External ToC : 0.2.4
MyST-Parser : 0.15.2
MyST-NB : 0.13.2
Sphinx Book Theme : 0.1.10
Jupyter-Cache : 0.4.3
NbClient : 0.5.13