diff --git a/nbconvert/exporters/webpdf.py b/nbconvert/exporters/webpdf.py index 183deeb0e..2d15b2b48 100644 --- a/nbconvert/exporters/webpdf.py +++ b/nbconvert/exporters/webpdf.py @@ -7,17 +7,13 @@ import concurrent.futures import os import tempfile +from importlib import util as importlib_util from traitlets import Bool, default from .html import HTMLExporter -try: - import pyppeteer # type:ignore # noqa - - PYPPETEER_INSTALLED = True -except ImportError: - PYPPETEER_INSTALLED = False +PYPPETEER_INSTALLED = importlib_util.find_spec("pyppeteer") is not None class WebPDFExporter(HTMLExporter): @@ -71,7 +67,7 @@ def _template_name_default(self): def _check_launch_reqs(self): try: - from pyppeteer import launch + from pyppeteer import launch # type: ignore[import] from pyppeteer.util import check_chromium # type:ignore except ModuleNotFoundError as e: msg = (