Jupyter-book: PDF print error: `pyppeteer.errors.NetworkError: Protocol error Page.printToPDF: Target closed`

Created on 15 Sep 2020  路  2Comments  路  Source: executablebooks/jupyter-book

Describe the bug

When trying to build the PDF for the gds_course (using make pdf, I run into the following error:

build succeeded, 87 warnings.

The HTML page is in website/_build/html.
Finished generating HTML for book...
Converting book HTML into PDF...
Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-book", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/jupyter_book/commands/__init__.py", line 171, in build
    html_to_pdf(OUTPUT_PATH.joinpath("index.html"), path_pdf_output)
  File "/opt/conda/lib/python3.7/site-packages/jupyter_book/pdf.py", line 19, in html_to_pdf
    asyncio.get_event_loop().run_until_complete(_html_to_pdf(html_file, pdf_file))
  File "/opt/conda/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/opt/conda/lib/python3.7/site-packages/jupyter_book/pdf.py", line 42, in _html_to_pdf
    await page.pdf({"path": pdf_file, "margin": page_margins})
  File "/opt/conda/lib/python3.7/site-packages/pyppeteer/page.py", line 1419, in pdf
    pageRanges=pageRanges
pyppeteer.errors.NetworkError: Protocol error Page.printToPDF: Target closed.
Makefile:34: recipe for target 'pdf' failed
make: *** [pdf] Error 1

To Reproduce

  1. Check out the repo: git clone https://github.com/darribas/gds_course.git
  2. Build PDF from the root folder of the repo: make pdf

Expected behavior

PDF generated

Environment

pyppeteer                 0.0.25                     py_1    conda-forge
bug

Most helpful comment

it turned out to be an easy one, dropping fix here in case it helps others. I was using conda install -c conda-forge pyppeteer which currently defaults to 0.0.25, with a long-standing issue. In any case, the issue is resolved on the latest version (0.2.2) from the new team behind pyppeteer. So making sure the installed version was 0.2.2 (offered both through pip and conda-forge) solved the issue.

Thanks very much for exploring these options, the PDFs generated are super nice!!!

Closing as considered resolved for this particular case.

All 2 comments

Hmmmm - I'm afraid I'm not sure how to debug these kinds of issues, it feels like an issue w/ pyppeteer moreso than Jupyter Book which I'm not super familiar with (which is why we're treating this as a very "alpha" feature). Have you looked around in the pyppeteer forums etc for references to "Target closed"?

it turned out to be an easy one, dropping fix here in case it helps others. I was using conda install -c conda-forge pyppeteer which currently defaults to 0.0.25, with a long-standing issue. In any case, the issue is resolved on the latest version (0.2.2) from the new team behind pyppeteer. So making sure the installed version was 0.2.2 (offered both through pip and conda-forge) solved the issue.

Thanks very much for exploring these options, the PDFs generated are super nice!!!

Closing as considered resolved for this particular case.

Was this page helpful?
0 / 5 - 0 ratings