Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How export a Jupyter notebook to HTML from the command line?

Tags:

I'm writing test visualization program based on test results. I want to run jupyter notebook via terminal and generate html page to show it to user without showing the editable scripts to user. Can I do that? Or suggest the better way to show visualized test results.

like image 988
Daniil Okhlopkov Avatar asked Apr 27 '16 21:04

Daniil Okhlopkov


People also ask

How do I export a Jupyter Notebook to HTML?

Jupyter Notebook's Built-In Capability: If including code, this is the easiest way to create the JNaaP. This method is as simple as clicking File, Download as, HTML (. html). Jupyter will then download the notebook as an HTML file to wherever the browser defaults for downloaded files.

How do I export my 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.

Can we use Jupyter Notebook for HTML?

Notebooks may be exported to a range of static formats, including HTML (for example, for blog posts), reStructuredText, LaTeX, PDF, and slide shows, via the nbconvert command. Furthermore, any . ipynb notebook document available from a public URL can be shared via the Jupyter Notebook Viewer <nbviewer>.


1 Answers

Also use --execute to get the output

jupyter nbconvert --execute --to html notebook.ipynb 

This produces a notebook.html file.

The best practice is to keep the output out of the notebook for version control, see: Using IPython notebooks under version control

But then, if you don't pass --execute, the output won't be present in the HTML, see also: How to run an .ipynb Jupyter Notebook from terminal?

For an HTML fragment without header: How to export an IPython notebook to HTML for a blog post?

Tested in Jupyter 4.4.0.