Juypter笔记本 - 从命令行ipython连接到相同的内核会话?

vic*_*orx 7 ipython jupyter-notebook

假设我在浏览器中加载了一个Jupyter笔记本.有可能以某种方式运行命令行ipython会话连接到与笔记本使用的相同的内核insance(即他们可以看到相同的变量集)?谢谢.

Mar*_*iet 9

是! 启动/加载IPython笔记本后,打开终端并使用以下--existing参数连接命令行ipython session :

jupyter console --existing
Run Code Online (Sandbox Code Playgroud)

默认情况下,它将连接到最新启动的IPython内核.要选择要连接的其他内核,请在Jupyter笔记本的日志中查找以下行:

[I 09:47:54.462 NotebookApp] Kernel started: 06c9ffae-ae9f-4c22-93c0-4eacf23672b1
Run Code Online (Sandbox Code Playgroud)

要连接到此内核,请执行以下操作:

jupyter console --existing 06c9ffae-ae9f-4c22-93c0-4eacf23672b1
Run Code Online (Sandbox Code Playgroud)