Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbconvert hangs indefinitely when trying to use webpdf export on Linux #1834

Open
joelostblom opened this issue Aug 13, 2022 · 4 comments
Open

Comments

@joelostblom
Copy link
Contributor

nbconvert hangs indefinitely when trying to use webpdf export on Linux (in a vm).

I tried installing both via pip install nbconvert[webpdf] and then run the export command with --allow-chromium-download. Then I tried conda install pyppeteer + pyppeteer-install, the freeze happens in both cases. HTML export works fine. The version of pyppeteer is 1.0.2 in both cases and I am using Python 3.10.4.

Minimal notebook to reproduce:
Untitled3.txt

Out put from the command: (base) joel@ubuntu2204:~$ jupyter nbconvert Untitled3.ipynb --to webpdf --debug --allow-chromium-download:

[NbConvertApp] Searching ['/home/joel', '/home/joel/.jupyter', '/home/joel/.local/etc/jupyter', '/home/joel/miniconda3/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files [NbConvertApp] Looking for jupyter_config in /etc/jupyter [NbConvertApp] Looking for jupyter_config in /usr/local/etc/jupyter [NbConvertApp] Looking for jupyter_config in /home/joel/miniconda3/etc/jupyter [NbConvertApp] Looking for jupyter_config in /home/joel/.local/etc/jupyter [NbConvertApp] Looking for jupyter_config in /home/joel/.jupyter [NbConvertApp] Looking for jupyter_config in /home/joel [NbConvertApp] Looking for jupyter_nbconvert_config in /etc/jupyter [NbConvertApp] Looking for jupyter_nbconvert_config in /usr/local/etc/jupyter [NbConvertApp] Looking for jupyter_nbconvert_config in /home/joel/miniconda3/etc/jupyter [NbConvertApp] Looking for jupyter_nbconvert_config in /home/joel/.local/etc/jupyter [NbConvertApp] Looking for jupyter_nbconvert_config in /home/joel/.jupyter [NbConvertApp] Looking for jupyter_nbconvert_config in /home/joel [NbConvertApp] Converting notebook Untitled3.ipynb to webpdf [NbConvertApp] Notebook name is 'Untitled3' [NbConvertApp] Template paths: /home/joel/miniconda3/share/jupyter/nbconvert/templates/webpdf /home/joel/miniconda3/share/jupyter/nbconvert/templates/lab /home/joel/miniconda3/share/jupyter/nbconvert/templates/base /home/joel/.local/share/jupyter /home/joel/.local/share/jupyter/nbconvert/templates /home/joel/.local/share/jupyter/nbconvert/templates/compatibility /home/joel/miniconda3/share/jupyter /home/joel/miniconda3/share/jupyter/nbconvert/templates /home/joel/miniconda3/share/jupyter/nbconvert/templates/compatibility /usr/local/share/jupyter /usr/local/share/jupyter/nbconvert/templates /usr/local/share/jupyter/nbconvert/templates/compatibility /usr/share/jupyter /usr/share/jupyter/nbconvert/templates /usr/share/jupyter/nbconvert/templates/compatibility /home/joel/miniconda3/share/jupyter/nbconvert/templates [NbConvertApp] Applying preprocessor: TagRemovePreprocessor [NbConvertApp] Applying preprocessor: RegexRemovePreprocessor [NbConvertApp] Applying preprocessor: coalesce_streams [NbConvertApp] Applying preprocessor: HighlightMagicsPreprocessor [NbConvertApp] Applying preprocessor: CSSHTMLHeaderPreprocessor [NbConvertApp] Attempting to load template index.html.j2 [NbConvertApp] template_paths: /home/joel/miniconda3/share/jupyter/nbconvert/templates/webpdf:/home/joel/miniconda3/share/jupyter/nbconvert/templates/lab:/home/joel/miniconda3/share/jupyter/nbconvert/templates/base:/home/joel/.local/share/jupyter:/home/joel/.local/share/jupyter/nbconvert/templates:/home/joel/.local/share/jupyter/nbconvert/templates/compatibility:/home/joel/miniconda3/share/jupyter:/home/joel/miniconda3/share/jupyter/nbconvert/templates:/home/joel/miniconda3/share/jupyter/nbconvert/templates/compatibility:/usr/local/share/jupyter:/usr/local/share/jupyter/nbconvert/templates:/usr/local/share/jupyter/nbconvert/templates/compatibility:/usr/share/jupyter:/usr/share/jupyter/nbconvert/templates:/usr/share/jupyter/nbconvert/templates/compatibility:/home/joel/miniconda3/share/jupyter/nbconvert/templates [NbConvertApp] Building PDF [INFO] Starting Chromium download. 100%|█████████████████████████████████████████████████████████████████| 109M/109M [00:19<00:00, 5.44Mb/s] [INFO] Beginning extraction [INFO] Chromium extracted to: /home/joel/.local/share/pyppeteer/local-chromium/588429

Nbconvert version:

jupyter --version

IPython          : 8.4.0
ipykernel        : 6.15.1
ipywidgets       : not installed
jupyter_client   : 7.3.4
jupyter_core     : 4.11.1
jupyter_server   : 1.18.1
jupyterlab       : 3.4.5
nbclient         : 0.6.6
nbconvert        : 6.5.3
nbformat         : 5.4.0
notebook         : 6.4.12
qtconsole        : not installed
traitlets        : 5.3.0
@jmcelroy01
Copy link

I also have this issue on Opensuse Tumbleweed (not a vm), with a pip install of nbconvert. Python version is 3.10.6. I let it run for about 30 minutes before cancelling. It hangs on the "[NbConvertApp] Building PDF" step.

ipykernel        : 6.15.1
ipywidgets       : 7.7.1
jupyter_client   : 7.3.4
jupyter_core     : 4.11.1
jupyter_server   : 1.18.1
jupyterlab       : 3.4.5
nbclient         : 0.6.6
nbconvert        : 6.5.3
nbformat         : 5.4.0
notebook         : 6.4.12
qtconsole        : 5.3.1
traitlets        : 5.3.0

@joelostblom
Copy link
Contributor Author

I have tried this outside a virtual machine now (Ubuntu 22.04 derivate) and have several students report the same issue. It seems to be an issue with sandbox mode and disabling it fixes the export. I am not sure if this currently affect all Linuxes but it seems worthwhile considering disabling sandbox mode by default on Linux, so that it is possible to use webexport without issues. In the meantime, this command disables the sandbox mode for both command line and graphical exports:

echo 'c.WebPDFExporter.disable_sandbox = True' > ~/.jupyter/jupyter_nbconvert_config.py && touch ~/.jupyter/jupyter_lab_config.py && echo 'c.WebPDFExporter.disable_sandbox = True' >> ~/.jupyter/jupyter_lab_config.py

Related issues and comments:

@SMZ70
Copy link

SMZ70 commented Nov 2, 2022

I have tried this outside a virtual machine now (Ubuntu 22.04 derivate) and have several students report the same issue. It seems to be an issue with sandbox mode and disabling it fixes the export. I am not sure if this currently affect all Linuxes but it seems worthwhile considering disabling sandbox mode by default on Linux, so that it is possible to use webexport without issues. In the meantime, this command disables the sandbox mode for both command line and graphical exports:

echo 'c.WebPDFExporter.disable_sandbox = True' > ~/.jupyter/jupyter_nbconvert_config.py && touch ~/.jupyter/jupyter_lab_config.py && echo 'c.WebPDFExporter.disable_sandbox = True' >> ~/.jupyter/jupyter_lab_config.py

Related issues and comments:

* [Webpdf export doesn't seem to work in K8s/JupyterHub/JupyterLab setting #1434 (comment)](https://github.com/jupyter/nbconvert/issues/1434#issuecomment-1209793194)

* [What is the official way for handling "--no-sandbox" situation? #1490](https://github.com/jupyter/nbconvert/issues/1490)

* [Not working pyppeteer/pyppeteer#373](https://github.com/pyppeteer/pyppeteer/issues/373)

* [Pyppeteer basic example doesn't work in docker image pyppeteer/pyppeteer#194](https://github.com/pyppeteer/pyppeteer/issues/194)

Thanks! Worked like a charm for me.

@Rivers47
Copy link

Rivers47 commented Jan 22, 2023

For me after using the above fix it still freezes in the web interface but I can convert successfully in command line with
jupyter nbconvert --to webpdf --allow-chromium-download notebook.ipynb

For some reason there are two identical entries "Download as PDF via html (.html)" entry in the webui (both freezes, one even stops the jupyter process to receive Kill)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants