3

Im using nbconvert to convert a notebook to pdf using the following code:

(base) C:\Users\25470\Desktop\Data Projects\Quantium Virtual Internship\Assingment 2>jupyter nbconvert task2.ipynb --to webpdf

I get the following output :

[NbConvertApp] Converting notebook task2.ipynb to webpdf
[NbConvertApp] Building PDF

then this error :

Traceback (most recent call last):
  File "d:\Anaconda3\Scripts\jupyter-nbconvert-script.py", line 10, in <module>
    sys.exit(main())
  File "d:\Anaconda3\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "d:\Anaconda3\lib\site-packages\traitlets\config\application.py", line 845, in launch_instance
    app.start()
  File "d:\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 350, in start
    self.convert_notebooks()
  File "d:\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 524, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "d:\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 489, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "d:\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 418, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "d:\Anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 181, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "d:\Anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 199, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "d:\Anaconda3\lib\site-packages\nbconvert\exporters\webpdf.py", line 93, in from_notebook_node
    pdf_data = self.run_pyppeteer(html)
  File "d:\Anaconda3\lib\site-packages\nbconvert\exporters\webpdf.py", line 83, in run_pyppeteer
    pdf_data = pool.submit(run_coroutine, main()).result()
  File "d:\Anaconda3\lib\concurrent\futures\_base.py", line 439, in result
    return self.__get_result()
  File "d:\Anaconda3\lib\concurrent\futures\_base.py", line 388, in __get_result
    raise self._exception
  File "d:\Anaconda3\lib\concurrent\futures\thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "d:\Anaconda3\lib\site-packages\nbconvert\exporters\webpdf.py", line 82, in run_coroutine
    return loop.run_until_complete(coro)
  File "d:\Anaconda3\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "d:\Anaconda3\lib\site-packages\nbconvert\exporters\webpdf.py", line 49, in main
    await page.goto('data:text/html,'+html, waitUntil='networkidle0')
  File "d:\Anaconda3\lib\site-packages\pyppeteer\page.py", line 885, in goto
    raise error
pyppeteer.errors.TimeoutError: Navigation Timeout Exceeded: 30000 ms exceeded.

What does it mean ? Other files convert ok. Myb the file size is the issue, the file is 2.5mb.

Youssef Razak
  • 365
  • 4
  • 11
  • I just encountered the same issue, and I have no idea how to fix this... – Næreen Feb 09 '21 at 19:10
  • I found out that the issue is with the size of the file. Hoping the developers will fix the bug. The best workaround is to download the notebook as HTML and convert that to pdf – Youssef Razak Feb 11 '21 at 08:32
  • I worked around this by using nbconvert -to html and then wkhtmltopdf (actually via a Python wrapper API, pdfkit) to convert to PDF. This has the advantage of better support for options like page size and margins, and it was still able to render a doc with plotly charts (with a long js timeout). – markfickett Apr 15 '23 at 01:53

0 Answers0