Is it possible to start an IPython notebook and QT-console working with the same kernel with one click?

StackOverflow https://stackoverflow.com/questions/22317312

  •  12-06-2023
  •  | 
  •  

Question

I would like to be able to start IPython notebook and a QTconsole connected to the same kernel. Theoretically, I can launch one of them, get kernel info and then connect the another one to that kernel. However, I would like to be able to do this in one command (I work on Windows). Is that possible?

Note: the documentation says that I can start qtconsole from a notebook using %qtconsole command. However, in my case I get the following error "ERROR: Could not start qtconsole: ValueError('close_fds is not supported on Windows platforms if you redirect stdin/stdout/stderr',)"

Was it helpful?

Solution

I'm running the latest IPython 2.1 with Anaconda 2.0.1.

There are some directions on this page which help you set up a IPython instance for hosting purposes. Here is how to tweak this to run locally.

run "ipython profile create nbserver" at the terminal/command prompt

In the profile directory just created, (usually ~/.ipython/profile_nbserver) edit the file ipython_notebook_config.py. By default, the file has all fields commented; the minimum set you need to uncomment and edit is the following:

c = get_config()

# Kernel config
c.IPKernelApp.pylab = 'inline'  # if you want plotting support always

# Notebook config
c.NotebookApp.ip = '*'               #or keep it 'localhost'
c.NotebookApp.open_browser = False
# It is a good idea to put it on a known, fixed port
c.NotebookApp.port = 9999

Then open 2 terminals/command_prompts so you can check if it works. In the first type (don't put an underscore in either line)

ipython console -i --profile nbserver

then type in that window a = 1

and the 2nd

ipython console -i --profile nbserver --existing

type print(a)

and yes... you can replace the word "console" with "notebook" or "qtconsole" (but for qt-console take out the -i switch)

Since you are on windows you could put those 2 commands in a script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top