Convert ipynb notebook to HTML in Google Colab

spaghetticode picture spaghetticode · Nov 24, 2018 · Viewed 25.6k times · Source

I have a Google Colaboratory Notebook for Data Analysis that I want to output as a HTML file as currently not everything loads within the Colab environment such as large Folium Heatmaps. Is it possible to export the notebook as a html file as opposed to the ipynb and py options?

Answer

zabop picture zabop · Oct 22, 2020

Method using only Google Colab

  1. Download your .ipynb file

You can actually do it using only Google Colab. File -> Download .ipynb


  1. Reupload it so Colab can see it

Click on the Files icon on the far left:

enter image description here

Then Upload to session storage:

enter image description here

Select & upload your .ipynb file you just downloaded.


  1. Get your file's path

then obtain its path (you might need to hit the Refresh button before your file shows up):

enter image description here


  1. Conversion using %%shell

Then, just as in Julio's answer, execute in a Colab cell:

%%shell
jupyter nbconvert --to html /PATH/TO/YOUR/NOTEBOOKFILE.ipynb

The %%shell lets the interpreter know that the following script is interpreted as shell. Don't write anything before %%shell, use a distinct cell for this.

The form of /PATH/TO/YOUR/NOTEBOOKFILE.ipynb will be something like /content/lightaberration3.ipynb.


  1. Your file is ready

Might need to click Refresh again, but your notebook.html will appear in the files, so you can download it:

enter image description here


The great thing about this is that nothing python-related has to be installed on your computer, not conda, not pip, only a browser.