title: How do I embed an IPython Interpreter into an application running in an IPython Qt Console
body: <p>There are a few topics on this, but none with a satisfactory answer. </p>
  
  <p>I have a python application running in an IPython qt console</p>
  
  <p><a href="http://ipython.org/ipython-doc/dev/interactive/qtconsole.html" rel="noreferrer">http://ipython.org/ipython-doc/dev/interactive/qtconsole.html</a></p>
  
  <p>When I encounter an error, I'd like to be able to interact with the code at that point. </p>
  
  <pre><code>    try: 
        raise Exception()
      except Exception as e:
          try: # use exception trick to pick up the current frame
              raise None
          except:
              frame = sys.exc_info()[2].tb_frame.f_back
          namespace = frame.f_globals.copy()
          namespace.update(frame.f_locals)
          import IPython
          IPython.embed_kernel(local_ns=namespace)  
  </code></pre>
  
  <p>I would think this would work, but I get an error: </p>
  
  <p>RuntimeError: threads can only be started once</p>