nbconvert:导出到另一个目录?

问题描述:

我想知道是否可以将Jupyter笔记本导出到与笔记本本身不同的目录中?我正在使用它来构建笔记本的HTML版本,并且希望它们位于我的GitHub存储库中的docs/下(这是为了利用GH页面).

I'm wondering if it's possible to export a Jupyter notebook to a different directory than the same directory as the notebook itself? I'm using this to build HTML versions of the notebooks, and I'd like them to reside under docs/ in my GitHub repo (this is to take advantage of GH-pages).

NBConvert的--output-dir参数执行此操作: https://nbconvert.readthedocs.io/en/latest/install.html

NBConvert's --output-dir argument does this: https://nbconvert.readthedocs.io/en/latest/install.html

您可以从命令行或在Jupyter笔记本中使用它.

You can use it from the command line or from within a Jupyter notebook.

命令行:

jupyter nbconvert --output-dir='./docs' --to html my_notebook_to_be_converted.ipynb

在Jupyter Notebook单元中:

!jupyter nbconvert --output-dir='./docs' --to html my_notebook_to_be_converted.ipynb

请注意,由于默认输出格式为html,因此无需使用"--to html"将笔记本转换为html.我只是为了清楚起见而加入了该论点.

Note that you don't need to use "--to html" to convert a notebook to html because the default output format is html. I've included the argument solely for clarity.