问题
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