Make slides with IPython notebook

I like using IPython notebook in my projects, it’s a great way of combining text, code and plots.
A bit like using R Markdown with RStudio, you can convert your notebook files to PDFs or HTML files. You can also show math formulas, embed images, videos and webpages.

To start a IPython notebook just type:

ipython notebook Example_Ipython.ipynb

When your are happy with your notebook there is a nice way of exporting IPython notebooks as slides, it’s just one line of code:

ipython nbconvert Example_Ipython.ipynb --to slides --post serve

An example notebook

A created an example notebook called Example_Ipython.ipynb.

  • Notebook:This is how the notebook looks like: (see here). It is not interactive because this link is just a ‘viewer’
  • Slides: This is how the slides look like: (see here)

IPython notebook is also useful for teaching, because its interactive, and students can change the code directly during class. It works great, we use it in our python courses at the University of Cambridge (http://pycam.github.io/).

How to install

All info on installing IPython here: http://ipython.org/install.html

I have a mac, and for me installing anaconda was v. straightforward:
The installation instructions are here: http://docs.continuum.io/anaconda/install.html
Then, I typically use ipython from anaconda, like this:

/Users/santia01/anaconda/bin/ipython notebook Example_Ipython.ipynb

Anaconda’s python distribution includes many useful scientific libraries such as NumPy, SciPy, IPython, PyTables, pandas, Matplotlib, scikit-learn, etc.

Note that nbconvert uses pandoc to convert between various markup languages, so, besides anaconda, you also needed to have pandoc installed.(http://johnmacfarlane.net/pandoc/installing.html).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s