Juypter notebook - connect to the same kernel session from a command line ipython?

北战南征 提交于 2020-04-08 10:05:34

问题


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.


回答1:


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

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


来源:https://stackoverflow.com/questions/43083966/juypter-notebook-connect-to-the-same-kernel-session-from-a-command-line-ipytho

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!