Using Jupyter Notebooks

Those who are interested in using Python or R but have not yet explored Jupyter notebooks (formerly know as IPython notebooks) should check them out without delay.

If you use Mathematica, you will find Jupyter notebooks familiar in look, feel, and function to Mathematica notebooks. Like Mathematica notebooks, a Jupyter notebook allows its users to bundle code, text, multimedia, and web content into a single portable object.

Jupyter notebooks open up in your web browser, and you can run code blocks and see the output directly in your browser.  While there is a remote web server-based option called Jupyterhub, which allows you to run your Jupyter notebooks on a remote machine via the web and can be great for collaboration, you don't need to run Jupyterhub.  You can run Jupyter notebooks on your machine by simply typing "jupyter notebook" in a terminal window whose working directory is where you keep Jupyter notebooks on your machine. Doing so launches a small web server on your machine that serves Jupyter notebooks — and the homepage is the directory holding your Jupyter notebooks.

Jupyter notebooks are designed to be programming-language agnostic. This means you can code for different programming languages in Jupyter notebooks.  You can run R, Python or Julia inside Jupyter notebooks.  You can do Jupyter magic calls for languages like bash, perl, or Ruby.  You can even pass data or variables between kernels.  Using the Sympy module, you can code symbolic mathematics. When you write LaTeX in a Markdown cell, it renders formulae in textbook format using MathJax. HTML code is allowed, including javascript.  As mentioned, web content is rendered in Jupyter notebooks. They do this via iframes. You can even include inline video and audio content.

The easiest way to share your notebook is simply via the notebook file (.ipynb) and associated files (such as image files you might point to within your Jupyter notebook); but for those colleagues who don’t use Jupyter, you have options for sharing your notebooks' content:

  • Convert them to a HTML file using the "File > Download as > HTML" menu option.
  • Convert them to a PDF file using the "File > Download as > PDF" menu option.
  • Share your notebook files with gists or on github, both of which render the notebooks.
  • Set up your own system with jupyterhub (this is very handy when you organize workshops or classes, so you don’t have to worry about what software is installed on the students' machines).

Written by Eric Rostetter, Senior System Administrator
Questions or comments? The best and easiest way to contact us is via the CNS Help Desk form.

See also: Software