I have an existing ipython kernel, with a communication file 'path/comm_file.json' and I want to execute code in this kernel using the Kernel Client API (actually I'm not picky, any method will do..). I understood that this is the best way to do things from the jupyter documentation. So I write the following code:
from jupyter_client import KernelClient
client = KernelClient(connection_file='path/comm_file.json')
client.execute('a = 10')
But the execute method leads to the following error:
File "C:\Python27\lib\site-packages\jupyter_client\client.py", line 249, in execute
self.shell_channel.send(msg)
File "C:\Python27\lib\site-packages\jupyter_client\client.py", line 143, in shell_channel
socket, self.session, self.ioloop
TypeError: object.__new__() takes no parameters
What am I doing wrong here??
I am also trying to figure out how the client works. Here's a place to start:
For a simple blocking client you can have a look a how jupyter_test_client and jupyter_console works.
You will need helper functions to handle properly the zmq channels and json messages.
I was able to make a simple and bare
KernelClient
work for me with this:That's indeed how
JupyterConsoleApp
(used by jupyter_console) initializes its client when an existing kernel file is given.