Is it possible to save a Google Colaboratory Notebook to HTML?
Google Colab doesn't currently have such a feature as a built-in.
Your best route is to first download it through File > Download .ipynb
and then use the standard tool for Jupyter Notebook conversion, nbconvert
:
jupyter nbconvert --to html notebook.ipynb
If you use an Anaconda Python distribution, nbconvert
is most likely already installed. If not, refer to what is described in their install instructions to be able to convert:
pip install nbconvert
# OR
conda install nbconvert
Method using only Google Colab
- Download your .ipynb file
You can actually do it using only Google Colab. File
-> Download .ipynb
- Reupload it so Colab can see it
Click on the Files
icon on the far left:
Then Upload to session storage
:
Select & upload your .ipynb
file you just downloaded.
- Get your file's path
then obtain its path (you might need to hit the Refresh
button before your file shows up):
- 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
.
- Your file is ready
Might need to click Refresh
again, but your notebook.html
will appear in the files, so you can download it:
The great thing about this is that nothing python-related has to be installed on your computer, not conda, not pip, only a browser.