Compiling nbconvert with Nuitka

Hi, does anyone here have any experience with compiling nbconvert with Nuitka? Even with the compilation option –-include-package-data=nbconvert I’m still getting this error with the compiled executable:

ImportError: cannot import name ‘PDFExporter’ from ‘nbconvert’

The program works fine in Python, it only fails as an executable compiled with Nuitka (with --onefile).

Here’s a small example: miek770/nbconvert-nuitka-test: Minimal example to test nbconvert’s PDFexporter with Nuitka

Unfortunately, all of the PDF exporters have a significant heavyweight runtime dependency which may stymie approaches like nuitika.

The original, PDFExporter, depends on the few hundred megabytes of a full $LaTeX$ environment, and probably pandoc.

WebPDFExporter uses playwright-python, which needs a few hundred megabytes of browser downloaded, and maybe nodejs (I can never tell anymore).

Of them, QtPDFExporter has a chance of working, but only just… it also uses a full, vendored chromium-derived browser, but qt is an important-enough dependency for standalone applications that someone may have already done some of the hard work.

2 Likes

I see, thank you! I’ll stick to my current solution: exporting to ipynb and letting users print to PDF from there.

1 Like