Skip to content

Instantly share code, notes, and snippets.

@RobinDavid
Created March 23, 2018 15:25
Show Gist options
  • Save RobinDavid/68ae562af2dd454fabe566cbcfbeb84e to your computer and use it in GitHub Desktop.
Save RobinDavid/68ae562af2dd454fabe566cbcfbeb84e to your computer and use it in GitHub Desktop.
Connecting programmatically (in python) to an existing jupyter kernel (from its file)
file = "/run/user/1000/jupyter/kernel-7365.json"
from jupyter_client.blocking import BlockingKernelClient
client = BlockingKernelClient(connection_file=file)
client.load_connection_file()
client.start_channels()
print(client.channels_running)
msgid = client.execute("3 + 5")
reply = client.get_shell_msg(timeout=3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment