The IPython Protocol

Frontends and Kernels

"Living the Dream!"

with [Paul Ivanov]( and [Thomas Kluyver](


(thanks to [Jonathan Frederic]( for last minute [presentation shortcuts](


The logistics of this presentation

What is IPython?

ipython universe

The punchline...

ipython universe

"Why should I care?"

Implement one piece - and get the others for free.

(free as in BSD)

This talk

ipython universe

Analogy (imperfect, but useful)

The WebIPython

speaks **HTTP** with

speaks "ICCP" with



Interactive Computing Communication Protocol

I wanted "IPython Protocol"

  • but IP was already taken :\

"Interactive Computing Protocol"


Computational Engine

- accepts messages

- performs actions

- sends out results

One-to-Many (Kernel to Clients)

console qtconsole vim-ipython vim-ipython bipython


Anatomy of a Message

In brief, read the messaging spec for more details.

Essential fields:

    msg_type: execute_request, execute_reply, object_info_request,
    complete_request, complete_reply, history_request, ...

parent_header: (see above)

content: structure depends on message type

    example: `execute_request`
        - `code` (str)
        - `silent` (bool)
        - `store_history` (bool)

    example: `execute_reply`
        - `status` ('ok', 'error', or 'abort')
        - `execution count` (prompt numbers)


- connects to exactly one kernel

- send messages to kernel based on user actions

- displays kernel messages when appropriate

Why have many clients?

Differences in

  • multiline editing
    • qtconsole
    • vim-ipython
    • notebook
  • display capabilities
    • images in qtconsole
    • images, video, javascript in notebook
  • persistence
    • no save and rerun in console, qtconsole
    • .ipynb files for notebook, EIN
    • files for vim-ipython
  • user interface
  • client-side requirements
    • python for console, qtconsle, vim-ipython, bipython
    • modern webbrowser for notebook
  • interactivity (bipython)


ship with ipython:

ipython qtconsole - the original decoupling, uses Qt4

ipython console - terminal version, decoupled

  • (different from the classic single process ipython)

both of these actually start a kernel and a client, pass --existing flag to not start a new kernel and instead simply connect to one that already exists ipython notebook ♦ ♦ - more on this later

vim plugin first written during the sprints at SciPy 2011

demo #1 demo #2

Live demo?

PSA: vim-ipython common problem (e.g. OS X)

Vim needs to be compiled with Python support (vim --version | grep +python) AND the Python linked must have IPython with ZeroMQ support

HOWEVER: the Python linked does not need to be your preferred Python.

Solution: either install IPython and PyZMQ into system Python, or compile vim against a Python which has IPython and PyZMQ (Python that comes with Anaconda, for example)

bipython logo

ripped out the messaging code from vim-ipython,

and slapped them on top of bpython's urwid interface 2 days.

Live Demo?

Embed is you friend!

In any Python code you have lying around, do this:

import IPython; IPython.embed_kernel()

When that code runs, it will prompt something like this:

NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see

To connect another client to this kernel, use:
    --existing kernel-5979.json

(demo if time permits)

Take away for clients

You favorite tool can talk (bi-directionally) to Python!


Bonus slides


ICCP over zermoq happens over multiple channels (3) not just one.

- stdin
- Shell ( action requests: execution, object introspection, code completion )
- IOPub ( "broadcast channel" )

What about the notebook? (analogy)

In [8]:
import IPython.display as d
In [10]:
d.IFrame("/files/notebook-as-proxy.html", 800, 600)