Mariano
Mariano

Reputation: 395

How to use nbconvert from Jupyter Notebook to HTML

I am trying to get a practical example to use nbconvert. I have seen a lot of blogs but I can get the idea right. How do I select the folder where the Jupyter notebook is located and the destination folder for the HTML output? what is the right syntaxis to do it using Windows? Thank you!!!

Upvotes: 3

Views: 6439

Answers (2)

Eduardo
Eduardo

Reputation: 1413

The other answer is outdated, so I'm sharing the updated version:

Run this in the terminal:

pip install nbconvert
jupyter nbconvert notebook.ipynb --to html

nbconvert is very flexible, for example, you can convert to pdf:

jupyter nbconvert notebook.ipynb --to pdf

And there are flavors to each format. For example, to get a barebones HTML (no CSS):

jupyter nbconvert notebook.ipynb --to html --template basic

Upvotes: 3

kuza
kuza

Reputation: 3031

If you not afraid of command line then it must be as simple and comprehensive as this example:

ipython nbconvert --to html "C:\path\to\your_notebook.ipynb"

It will generate a HTML file named your_notebook.html at same place where your_notebook.ipynb is located.

If you need to take control over target HTML file generation you can ask ipython to output into standard output and redirect its output to whatever file you want.

Example:

ipython nbconvert --to html "C:\path\to\your_notebook.ipynb" --stdout > "C:\my\reports\fancy_analytic.html"

This will render your_notebook.ipynb in HTML format into fancy_analytics.html file.

More info here

Upvotes: 2

Related Questions