Juypter笔记本-从命令行ipython连接到同一内核会话吗? [英] Juypter notebook - connect to the same kernel session from a command line ipython?

查看:76
本文介绍了Juypter笔记本-从命令行ipython连接到同一内核会话吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我已经在浏览器中加载了Jupyter笔记本.是否可以通过某种方式运行一个命令行ipython会话,该会话连接到与笔记本使用的内核实例相同的内核实例(即它们可以看到相同的变量集)?谢谢.

Suppose I've a Jupyter notebook loaded in a browser. Is that possible to somehow run a command line ipython session which connect to the same kernel insance as the one used by the notebook (i.e they can see the same set of variables)? Thanks.

推荐答案

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

Yes! After starting/loading an IPython notebook, open up a terminal and connect a command line ipython session using the --existing parameter:

jupyter console --existing

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

By default, it will connect to the latest started IPython kernel. To select a different kernel to connect to, look in the log of the Jupyter notebook for lines like these:

[I 09:47:54.462 NotebookApp] Kernel started: 06c9ffae-ae9f-4c22-93c0-4eacf23672b1

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

To connect to this kernel, do:

jupyter console --existing 06c9ffae-ae9f-4c22-93c0-4eacf23672b1

这篇关于Juypter笔记本-从命令行ipython连接到同一内核会话吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆