+
+---------------------------------------------------------------------------
+NetworkError Traceback (most recent call last)
+Cell In[3], line 72
+ 63 pdf_output_file = "slides.pdf"
+ 65 pool = concurrent.futures.ThreadPoolExecutor()
+ 66 pool.submit(
+ 67 asyncio.run,
+ 68 html_to_pdf(
+ 69 html_input_file,
+ 70 pdf_output_file
+ 71 ),
+---> 72 ).result()
+
+File ~/anaconda3/lib/python3.11/concurrent/futures/_base.py:456, in Future.result(self, timeout)
+ 454 raise CancelledError()
+ 455 elif self._state == FINISHED:
+--> 456 return self.__get_result()
+ 457 else:
+ 458 raise TimeoutError()
+
+File ~/anaconda3/lib/python3.11/concurrent/futures/_base.py:401, in Future.__get_result(self)
+ 399 if self._exception:
+ 400 try:
+--> 401 raise self._exception
+ 402 finally:
+ 403 # Break a reference cycle with the exception in self._exception
+ 404 self = None
+
+File ~/anaconda3/lib/python3.11/concurrent/futures/thread.py:58, in _WorkItem.run(self)
+ 55 return
+ 57 try:
+---> 58 result = self.fn(*self.args, **self.kwargs)
+ 59 except BaseException as exc:
+ 60 self.future.set_exception(exc)
+
+File ~/anaconda3/lib/python3.11/asyncio/runners.py:190, in run(main, debug)
+ 186 raise RuntimeError(
+ 187 "asyncio.run() cannot be called from a running event loop")
+ 189 with Runner(debug=debug) as runner:
+--> 190 return runner.run(main)
+
+File ~/anaconda3/lib/python3.11/asyncio/runners.py:118, in Runner.run(self, coro, context)
+ 116 self._interrupt_count = 0
+ 117 try:
+--> 118 return self._loop.run_until_complete(task)
+ 119 except exceptions.CancelledError:
+ 120 if self._interrupt_count > 0:
+
+File ~/anaconda3/lib/python3.11/asyncio/base_events.py:650, in BaseEventLoop.run_until_complete(self, future)
+ 647 if not future.done():
+ 648 raise RuntimeError('Event loop stopped before Future completed.')
+--> 650 return future.result()
+
+Cell In[3], line 24, in html_to_pdf(html_file, pdf_file, pyppeteer_args)
+ 21 await page.setViewport(dict(width=994, height=768))
+ 22 await page.emulateMedia("screen")
+---> 24 await page.goto(f"file://{html_file}", {"waitUntil": ["networkidle2"]})
+ 26 page_margins = {
+ 27 "left": "20px",
+ 28 "right": "20px",
+ 29 "top": "30px",
+ 30 "bottom": "30px",
+ 31 }
+ 33 dimensions = await page.evaluate(
+ 34 """() => {
+ 35 return {
+ (...)
+ 42 }"""
+ 43 )
+
+File ~/anaconda3/lib/python3.11/site-packages/pyppeteer/page.py:829, in Page.goto(self, url, options, **kwargs)
+ 826 timeout = options.get('timeout', self._defaultNavigationTimeout)
+ 827 watcher = NavigatorWatcher(self._frameManager, mainFrame, timeout, options)
+--> 829 result = await self._navigate(url, referrer)
+ 830 if result is not None:
+ 831 raise PageError(result)
+
+File ~/anaconda3/lib/python3.11/site-packages/pyppeteer/page.py:843, in Page._navigate(self, url, referrer)
+ 842 async def _navigate(self, url: str, referrer: str) -> Optional[str]:
+--> 843 response = await self._client.send('Page.navigate', {'url': url, 'referrer': referrer})
+ 844 if response.get('errorText'):
+ 845 return f'{response["errorText"]} at {url}'
+
+NetworkError: Protocol error (Page.navigate): Cannot navigate to invalid URL
+