The Jupyter project includes a tool for format conversion called nbconvert. It is easy to invoke from the command line:
jupyter nbconvert <file>.ipynb
It leaves the original <file>.ipynb
alone and produces as output <file>.html
. For example, we can transform a previous example as follows:
(Ipython)-bash-4.1$ jupyter nbconvert notebook2.ipynb [NbConvertApp] Converting notebook notebook2.ipynb to html [NbConvertApp] Writing 214390 bytes to notebook2.html (Ipython)-bash-4.1$ ls HelloWorld.ipynb img7.png notebook2.html notebook2.ipynb testnotebook.ipynb
This results in a 214K HTML file that displays as:
Note that the HTML preserves the full text of the code used to produce the plot, just in a read-only format. This can be important when using Jupyter as a method of disseminating research results, as readers can see the actual code used to produce the graph.