[IPython-dev] ipython notebook

MinRK benjaminrk at gmail.com
Tue Apr 24 14:24:44 EDT 2012

On Tue, Apr 24, 2012 at 10:42, Ralf Hemmecke <hemmecke at gmail.com> wrote:

> Thank you, Fernando.
> >> Is the notebook suited for this purpose or is it too much tied to
> >> python?
> >
> > Indeed, it would be possible to do so; recently an enterprising user
> > did just that as a test with Ruby:
> >
> > https://github.com/isotope11/iruby
>  From what I figured out so far, but Josh Adams modified ipython
> (https://github.com/isotope11/ipython/tree/ruby_kernel) in order to
> start ruby.

The *only* modification he needed to make to IPython was to change the
CodeMirror language to Ruby.
The rest was just subclassing and configuration.

> Not that I understood everything, I wonder why ipython does not include
such kind of talking to an external interpreter.

IPython does not include kernels in a dozen other languages because each
one must have an implementation of the kernel.

There are two ways to implement a new kernel:

1. translate the existing kernel into the target language. This would have
to include complying with message spec and serialization, etc.
2. subclass existing Kernel, to call out to a subprocess for execution.
 This would save a lot of work, particularly if all you want to do is
simple stdin/stdout, but would be inefficient, as it adds yet another
process/network hop to the mix, and only appropriate for supporting
languages that don't do much interactively.

This is all work that has to be done, and it is work that is going to be
done by people who want to use these other languages in the notebook (i.e.
not IPython devs). We are happy to help contributors with this work, but it
will not be us who write it.

> > Unfortunately we haven't had the time to write a detailed design
> > document that explains how the entire architecture works for someone
> > in your position.
> Understandable, but may I still ask for the big picture.
> Let me guess.
> (a) The client side is done with JavaScript. This is responsible for
> code highlighting, tab completion and what not.


> (b) JavaScript is probably talking (via 0MQ) to some python process on
> the server in order to get information of what to highlight and what to
> complete

Close: js talks websockets, which are translated to zmq by the nb server.

Completion is handled in the kernel, but highlighting is purely js

> (c) The input string is sent (probably in json format) to the server.
> (d) The server sends a json format of the output back to the client.
> Of course, I want different highlighting. Which function is responsible
> for that? How (for simplicity) could I simply switch that off?

Highlighting is done by CodeMirror, and the language is selected
We have not exposed UI to change the highlighting language, but it
wouldn't be difficult.  If your language is not already supported by
I think you have to add the highlighting spec.

> Same question for completion.
> I have to start an external process (fricas in my case) and send input
> to it and receive its output. Which functions are responsible for that?

The launch_kernel function in a KernelManager

> > So I'm afraid that making progress will require a fair amount of
> > reading the source and experimenting.  But don't be afraid to ask
> > here!
> If I don't disturb people here too much...
> What I don't see at the moment is in how far the notebook is tied to
> python. In some .ipynb file, I've seen "language: python" which seemed
> to be connected to one cell. That made me wonder whether you've already
> thought about having an input cell in another language. Since I would
> have to add the fricas language, where would I do this?

This code would be *entirely* in the javascript - it's just a metadata
field on the Cell,
and it would only be a few lines to make it editable.

> >> From our perspective, this is *absolutely* something we'd like to
> >> see out there.
> That's good. At least it sounds like I will be going a supported path.
> > Just today I was talking to a statistician friend and we were
> > discussing the possibility of an R notebook frontend.  That's also
> > something that would be great to have, and likely very useful.
> Yep. In fact, it would be wonderful, if one could have a multi-language
> environment in one notebook. The SageNotebook has something like this,
> but it cannot currently run without Sage and I am actually looking for
> something lighter.
> BTW, I installed ipython into a virtualenv. However, I was unable to get
> it running with ZeroMQ installed in my HOME. I would be grateful, if I
> can learn about installing ipython with with ZeroMQ not under /usr/local.

This should be easy, just configure zeromq with the virtualenv prefix (or
any other prefix, for that matter):


curl -O http://download.zeromq.org/zeromq-$version.tar.gz
tar -xzf zeromq-$version.tar.gz
cd zeromq-$version
./configure --prefix=$VIRTUAL_ENV
make && make install

# and install pyzmq, ensuring it knows where to look for libzmq:

pip install pyzmq --install-option="--zmq=$VIRTUAL_ENV"


> Regards
> Ralf
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20120424/4c23105d/attachment.html>

More information about the IPython-dev mailing list