Skillversitas

Connecting QtConsole to a Notebook

The power move with qtconsole is attaching it to a kernel that a notebook already owns. You get the notebook's variables in the console, and anything you compute in the console shows up in the notebook - one kernel, two frontends, sharing all state.

Find the Kernel

jupyter kernels list
# 1a2b3c4d-e5f6-... mynotebook.ipynb (user)
# the kernel ID is the first token

Attach by ID

jupyter qtconsole --kernel=1a2b3c4d-e5f6-...

Or, if it is the only kernel, --existing. The console window now shows the kernel's namespace: run %who and you will see every variable the notebook defined.

Try It

# in the notebook cell:
x = 42

# in the attached qtconsole:
x * 2        # 84
%who         # includes x

Set a variable in the console (y = "from console") and reference it in a notebook cell - it is there.

Multiple Frontends on One Kernel

Any number of clients can attach to a single kernel: a browser notebook, a qtconsole, a JupyterLab session. Execution is serialized (one cell at a time), but state is shared. Use this to debug a stuck notebook: open the console, interrupt there, inspect the namespace.

Remote Kernels

jupyter qtconsole --remote ssh://myserver:8888
# or point at a kernel manager behind a tunnel:
jupyter qtconsole --existing=127.0.0.1:8888

With SSH or an SSH tunnel to the notebook server's port, a local qtconsole drives a kernel running on a remote machine - the classic HPC workflow.

Summary

List kernels with jupyter kernels list, then attach with jupyter qtconsole --kernel=ID or --existing. The console and notebook share one kernel's namespace in both directions, multiple frontends can attach to the same kernel, and --remote or an SSH tunnel lets a local console drive a remote kernel.