Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Juypter notebook - connect to the same kernel session from a command line 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.

like image 766
victorx Avatar asked Mar 29 '17 03:03

victorx


People also ask

How do I run IPython notebook from command line?

3.1. Click on spotlight, type terminal to open a terminal window. Enter the startup folder by typing cd /some_folder_name . Type jupyter notebook to launch the Jupyter Notebook App The notebook interface will appear in a new browser window or tab.

Can two people work on Jupyter at the same time?

The new collaborative editing feature enables collaboration in real-time between multiple clients without user roles. When sharing the URL of a document to other users, they will have access to the same environment you are working on (they can e.g. write and execute the cells of a notebook).


2 Answers

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
like image 93
Marijn van Vliet Avatar answered Oct 19 '22 18:10

Marijn van Vliet


With JupyterLab it's possible to open a linked console by right clicking on any Notebook and selecting New Console for Notebook (as mentioned in @machine_building's comment on this answer). That will show a connected console beside/below the Notebook, which one can interact with like in a terminal with command history etc.

like image 1
Pierz Avatar answered Oct 19 '22 18:10

Pierz