IPython: how to connect to an existing kernel?

I can connect two ipython console sessions to one core:

 $ ipython console In [1]: %connect_info { ... Content of JSON with info for connecting ... } Paste the above JSON into a file, and connect with: $> ipython <app> --existing <file> or, if you are local, you can connect with just: $> ipython <app> --existing kernel-43204.json or even just: $> ipython <app> --existing if this is the most recent IPython session you have started. 

And accordingly, I can again replace <app> with the console

 $ ipython console --existing kernel-43204.json 

However, I want to share my kernel with an ipython laptop so that I can visualize my data. I tried and failed:

 $ ipython notebook --existing kernel-43204.json [C 13:35:01.025 NotebookApp] Unrecognized flag: '--existing' 

Any suggestion how can I work and switch between ipython console and ipython notebook ?

+12
source share
3 answers

There is no user interface or API for this; there is an assumption about the simplicity of the code that the laptop is the one who owns and runs the kernel. You will need to write your own subclass of KernelManager and configure IPython to use it (+ write some user interface code if you want it to be easy to use) so that you can select an existing kernel.

+8
source

Here is an example of a custom kernel manager that allows a Jupyter laptop to create a kernel created externally.

https://github.com/ebanner/extipy

This is a hacker solution at best.

We hope that Jupyter people can create such a core class of the regular type, include it in the package, and include it with a simple existing key. I see no reason why they cannot do this.

0
source

I will give you a solution on the contrary. Instead of connecting the laptop to an existing kernel, you can easily connect an ipython session to the kernel that was started by the laptop.

  1. Start your notebook. Now you have a working kernel.
  2. In the code cell, execute the %qtconsole magic command

Now you have a console and a laptop connected to the same core. You can control magic several times and have multiple consoles.

By the way, qtconsole is a very smart console. This is even better than terminal, especially if you are a Windows user.

0
source

All Articles