Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nbconvert: exporting to another directory?

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).

like image 509
ericmjl Avatar asked May 21 '17 16:05

ericmjl


People also ask

Can you export a Jupyter Notebook?

The Jupyter Notebook has an option to export the notebook to many formats. It can be accessed by clicking File -> Download as -> PDF via LaTeX (or PDF via HTML - not visible in the screenshot). This approach requires you to install some additional packages.

How do I export a python notebook?

You can export to a variety of formats from within the notebook by navigating to File -> Download As. You'll want to export your notebook as a Jupyter Interactive Notebook ( . ipynb file format) if you'd like the person you're sharing it with to interact with the notebook.

How do I convert Aipynb to PDF?

Create a notebook and the click "File -> Download As". Click the new menu entry called "PDF via HTML". Your notebook will be converted to a PDF on the fly and then downloaded.


1 Answers

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

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

Command line:

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

From within a Jupyter Notebook cell:

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

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.

like image 96
user6481870 Avatar answered Sep 28 '22 00:09

user6481870