简体   繁体   中英

How to convert Jupyter notebook to PDF?

How to convert Jupyter notebook to pdf, only obtaining the markdown cells and output?

I am having difficulty using Jupyter nbconvert to export my Jupyter notebook to a pdf. I would like the pdf to show my markdown cells and the output of the cells but NOT the code. For the purpose of this question the name of my notebook is Deskbook.ipynb. I have been trying these commands from the same working directory of the notebook.

I have attempted this in the notebook itself, as follows:

!ipython nbconvert --to pdf --no-input Deskbook.ipynb

and the error I receive is

ipython: error: unrecognized arguments: --no-input Deskbook.ipynb

I have also tried the following on a Mac terminal

% $jupyter nbconvert --to pdf --no-input Deskbook.ipynb

and the error I receive is

zsh: command not found: nbconvert

I have also tried the same command in the the Jupyter notebook, python shell (through Terminal on Mac and AnacondaPrompt.exe on my Windows 10 Thinkpad), and receive the following error:

 $jupyter nbconvert --to pdf --no-input 'Deskbook.ipynb'
    ^
SyntaxError: invalid syntax

Ideally, I would like to add the functionality of converting to pdfs in a cell at the end of the notebook. The reason I am doing this is to share the output of my notebook (Figures and html rendered Pandas dataframes) with people who do not code. I have also tried to download using the drop down menu in Jupyter, and while PDF via latex does work, my tables are all scrambled in the file. I have seen a variety of answers about this on stack overflow, but none seem to be working for me. I have access to both a Windows 10 and Mac OS Big Sur setup

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM