Code, Jupyter, Notes

Convert Interactive Jupyter Notebook into a Website

Bla bla… here’s what you have to do:

  1. Install nbinteract: pip install nbinteract
    (even if you have anaconda installed, use pip)
  2. Create a git repo for your project – this is important otherwise nbinteract will NOT run
    1. Make your repo public
    2. Under settings, enable pages (so that you can host your code on your github.io)
  3. Clone your repo locally
  4. Build your beautiful jupyter notebook with Interative widgdets: mynotebook.ipynb
  5. Open a terminal through jupyter – it is very important that you trigger nbinteract from a Jupyter terminal!
    1. navigate to the directory of your project
    2. nbinteract init (it will spit out some messages, and then ask you to create a sample requirements file – accept!)
    3. Edit your requirements.txt file. Simply list any additional python libs that you are using
    4. re-run nbinteract init
    5. commit and push your changes
    6. nbinteract mynotebook.ipynb will now create a mynotebook.html page!
    7. commit and push your changes.

This will create a binder image for your repo which will run your python code etc… You can now open the html page locally or put it on your website or open it through you github.io

You may see a temp error (like a module not found). Just be patient for the docker image to load on binder.

Voila!

Hint of the decade:

To hide code cells from showing up on your website, put #HIDDEN at the top of a cell