Does anyone have experience exporting Jupyter notebooks to PDF? I found information to do this (https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex), although it seems to require the use of 'sudo' (sudo apt-get install texlive-xetex texlive-fonts-recommended texlive-generic-recommended), which I believe we are not encouraged (or allowed?) to do on Cheyenne or Casper.
you could sync to your local machine and do it there. I haven't done it on CISL systems
Alternatively, it looks like texlive
is on conda: https://anaconda.org/conda-forge/texlive-core so
$ conda install -c conda-forge texlive-core
might be enough (I'm not familiar with it, so I don't know if xetex
and those fonts are needed... if so, there's a chance they're included in -core
on conda)
I think you'd want to install that package in a new environment rather than the one you run the notebook in, so maybe
$ conda create -c conda-forge --name nb_to_pdf texlive-core
would be a better suggestion
Thanks @Michael Levy ! I installed the new environment as suggested, but I can't figure out how to use it. I typically use JupyterHub and restarted my session but don't see it available as a kernel. I can activate it on Cheyenne, but I'm not sure how to open and convert a notebook from the command line. Any suggestions?
A quick follow up: I did try jupyter nbconvert --to pdf notebook.ipynb
, but got an error message that I need to install xelatex (OSError: xelatex not found on PATH, if you have not installed xelatex you may need to do so.
). You had mentioned that they may be in -core
on conda, but I'm not sure how to check and potentially use this.
It looks like there's a texlive-selected
package: https://anaconda.org/pkgw/texlive-selected that might include xetex
but I can't find any documentation on it (also, I don't know what the pkgw/label/superseded
channel is)
$ conda install -c pkgw/label/superseded texlive-selected
Hmm, pkgw
might be a person, and he says
The set of Texlive packages in my texlive-selected recipe has enough to run nbconvert
https://github.com/conda-forge/texlive-core-feedstock/issues/3#issuecomment-227024540
but that's pretty vague...
I'm beginning to think that my suggestion to bring in texlive via conda was a bad one, sorry
Have you tried the texlive
module that CISL is maintaining? Does it have xelatex?
$ module spider texlive -------------------------------------------------------------------------------------------------------- texlive: texlive/2018 -------------------------------------------------------------------------------------------------------- This module can be loaded directly: module load texlive/2018
@Danica Lombardozzi, in case the PDF creation via Latex option doesn't work, you may find the notebook-as-pdf
package to be an easier alternative. It doesn't require Latex and is easy to set up:
conda create -c conda-forge --name nb_to_pdf jupyterlab pip
conda activate nb_to_pdf conda install -c conda-forge jupyterlab pip python -m pip install -U notebook-as-pdf pyppeteer-install
jupyter-nbconvert --to PDFviaHTML mynotebook.ipynb
Thanks @Anderson Banihirwe ! That did the trick! I appreciate all the help from both you and @Michael Levy !
Of course! Glad it was successful
Last updated: May 16 2025 at 17:14 UTC