Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using IPython console along side IPython notebook

While working on an IPython notebook, I'm increasingly finding myself wishing that the notebook would have a console attached to it, for interactive programming. I find myself adding lines to test snippets of code and then deleting them and that's the good usage. In the worse usage I'm changing the commands in the same line, evaluating the line over and over, changing entirely the purpose of the line until I get it right, and then I'm Ctrl-Zing all the way back to the original cell content.

If I could have an interactive interpreter at the bottom of the notebook, that would definitely increase my productivity. I know that a notebook has a kernel, but I wasn't able to attach a new ipython console to it. So my wonders are:

  1. Is there a more efficient way to work with the notebook?
  2. Assuming there isn't, how can I attach an ipython console to a notebook kernel?

Thanks!

like image 348
idoda Avatar asked Oct 20 '13 16:10

idoda


People also ask

How do I open the console in Jupyter Notebook?

Once you've entered your specific folder with Windows Explorer, you can simply press ALT + D, type in cmd and press Enter. You can then type jupyter notebook to launch Jupyter Notebook within that specific folder.

Is Jupyter Notebook same as IPython?

The IPython Notebook is now known as the Jupyter Notebook. It is an interactive computational environment, in which you can combine code execution, rich text, mathematics, plots and rich media. For more details on the Jupyter Notebook, please see the Jupyter website.

How do I use IPython console?

The IPython Console allows you to execute commands and interact with data inside IPython interpreters. To launch a new IPython instance, go to New console (default settings) under the Consoles menu, or use the keyboard shortcut Ctrl - T ( Cmd - T on macOS) when the console is focused.

How do I run IPython notebook in terminal?

3.1. To launch Jupyter Notebook App: 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.


1 Answers

Just do %qtconsole in one cell, and it will start a qtconsole attached to the same kernel. Of course your kernel need to be local.

you can of course use the long method :

In [1]: %connect_info {   "stdin_port": 50845,    "ip": "127.0.0.1",    "control_port": 50846,    "hb_port": 50847,    "signature_scheme": "hmac-sha256",    "key": "c68e7f64-f764-4417-ba3c-613a5bf99095",    "shell_port": 50843,    "transport": "tcp",    "iopub_port": 50844 }  Paste the above JSON into a file, and connect with:     $> ipython <app> --existing <file> or, if you are local, you can connect with just:     $> ipython <app> --existing kernel-45781.json  or even just:     $> ipython <app> --existing  if this is the most recent IPython session you have started. 

then

 ipython qtconsole --existing kernel-45781.json 
like image 120
Matt Avatar answered Sep 18 '22 10:09

Matt