简体   繁体   English

如何将 Jupyter notebook 转换为 PDF?

[英]How to convert Jupyter notebook to PDF?

How to convert Jupyter notebook to pdf, only obtaining the markdown cells and output?如何将Jupyter笔记本转换为pdf,只获取markdown单元格和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.我在使用 Jupyter nbconvert 将我的 Jupyter 笔记本导出到 pdf 时遇到困难。我希望 pdf 显示我的 markdown 单元格和单元格的 output 但不是代码。 For the purpose of this question the name of my notebook is Deskbook.ipynb.出于这个问题的目的,我的笔记本的名称是 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我还在 Mac 终端上尝试过以下操作

% $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 笔记本 python shell 中尝试了相同的命令(通过 Mac 上的终端和我的 Windows 10 Thinkpad 上的 AnacondaPrompt.exe),并收到以下错误:

 $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.理想情况下,我想在笔记本末尾的单元格中添加转换为 pdf 的功能。 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.我这样做的原因是为了与不编码的人分享我笔记本的 output(数字和 html 渲染的 Pandas 数据帧)。 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.我还尝试使用 Jupyter 中的下拉菜单进行下载,虽然 PDF 通过 latex 确实有效,但我的表格都在文件中被打乱了。 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我可以访问 Windows 10 和 Mac OS Big Sur 设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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