Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run qtconsole with existing kernel in jupyter-client 7 #519

Open
ghost opened this issue Jan 16, 2022 · 4 comments
Open

Cannot run qtconsole with existing kernel in jupyter-client 7 #519

ghost opened this issue Jan 16, 2022 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 16, 2022

Issue description

Unable to run qtconsole with existing kernel

Steps to reproduce

  1. launch a kernel
$ jupyter notebook

select a new Python 3 notebook

  1. run qtconsole, connecting to existing kernel
$ jupyter qtconsole --existing

The QtConsole window appears and is blank. The error output is shown below.

ERROR:tornado.general:Uncaught exception in ZMQStream callback
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
    callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/jupyter_client/threaded.py", line 121, in _handle_recv
    msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
    self._check_running()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
    raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:tornado.general:Uncaught exception in zmqstream callback
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 452, in _handle_events
    self._handle_recv()
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 481, in _handle_recv
    self._run_callback(callback, msg)
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
    callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/jupyter_client/threaded.py", line 121, in _handle_recv
    msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
    self._check_running()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
    raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:asyncio:Exception in callback BaseAsyncIOLoop._handle_events(20, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(20, 1)>
Traceback (most recent call last):
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/user/.local/lib/python3.9/site-packages/tornado/platform/asyncio.py", line 189, in _handle_events
    handler_func(fileobj, events)
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 452, in _handle_events
    self._handle_recv()
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 481, in _handle_recv
    self._run_callback(callback, msg)
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
    callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/jupyter_client/threaded.py", line 121, in _handle_recv
    msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
    self._check_running()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
    raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:tornado.general:Uncaught exception in ZMQStream callback
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
    callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/jupyter_client/threaded.py", line 121, in _handle_recv
    msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
    self._check_running()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
    raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:tornado.general:Uncaught exception in zmqstream callback
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 452, in _handle_events
    self._handle_recv()
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 481, in _handle_recv
    self._run_callback(callback, msg)
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
    callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/jupyter_client/threaded.py", line 121, in _handle_recv
    msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
    self._check_running()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
    raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:asyncio:Exception in callback BaseAsyncIOLoop._handle_events(18, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(18, 1)>
Traceback (most recent call last):
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/user/.local/lib/python3.9/site-packages/tornado/platform/asyncio.py", line 189, in _handle_events
    handler_func(fileobj, events)
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 452, in _handle_events
    self._handle_recv()
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 481, in _handle_recv
    self._run_callback(callback, msg)
  File "/home/user/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
    callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/jupyter_client/threaded.py", line 121, in _handle_recv
    msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
    self._check_running()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
    raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
/usr/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/utils.py:8: RuntimeWarning: coroutine 'get_msg' was never awaited
  from .tags import Tag, parse_tag
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/usr/lib/python3.9/site-packages/pkg_resources/_vendor/pyparsing.py:3270: RuntimeWarning: coroutine 'get_msg' was never awaited
  if all(isinstance(expr, basestring) for expr in exprs):
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Environment

_$ pip list --user | grep jupyter
jupyter              1.0.0
jupyter-client       7.1.1
jupyter-console      6.4.0
jupyter-core         4.9.1
jupyterlab-pygments  0.1.2
jupyterlab-widgets   1.0.2
_$ pip list --user | grep ipy
ipykernel            6.7.0
ipython              8.0.0
ipython-genutils     0.2.0
ipywidgets           7.6.5
_$ pip list --user | grep zmq
pyzmq                22.3.0
_$ python --version
Python 3.9.9
_$ cat ~/.jupyter/jupyter_qtconsole_config.py
c = get_config()

c.ConsoleWidget.scrollbar_visibility = False

c.ConsoleWidget.font_family = "Inconsolata"
c.ConsoleWidget.font_size = 14

c.JupyterQtConsoleApp.hide_menubar = True

c.JupyterWidget.include_other_output = True
@ghost
Copy link
Author

ghost commented Jan 16, 2022

I repeated the above with the current main branch of python_console, qtconsole, and jupyter_client, and got the same issue with a similar error message (below)

Error
ERROR:tornado.general:Uncaught exception in ZMQStream callback
Traceback (most recent call last):
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
   callback(*args, **kwargs)
 File "/home/user/jupyter-test/jupyter_client/jupyter_client/threaded.py", line 121, in _handle_recv
   msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
 File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
   self._check_running()
 File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
   raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:tornado.general:Uncaught exception in zmqstream callback
Traceback (most recent call last):
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 452, in _handle_events
   self._handle_recv()
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 481, in _handle_recv
   self._run_callback(callback, msg)
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
   callback(*args, **kwargs)
 File "/home/user/jupyter-test/jupyter_client/jupyter_client/threaded.py", line 121, in _handle_recv
   msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
 File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
   self._check_running()
 File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
   raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:asyncio:Exception in callback BaseAsyncIOLoop._handle_events(20, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(20, 1)>
Traceback (most recent call last):
 File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
   self._context.run(self._callback, *self._args)
 File "/home/user/jupyter-test/lib/python3.9/site-packages/tornado/platform/asyncio.py", line 189, in _handle_events
   handler_func(fileobj, events)
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 452, in _handle_events
   self._handle_recv()
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 481, in _handle_recv
   self._run_callback(callback, msg)
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
   callback(*args, **kwargs)
 File "/home/user/jupyter-test/jupyter_client/jupyter_client/threaded.py", line 121, in _handle_recv
   msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
 File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
   self._check_running()
 File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
   raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:tornado.general:Uncaught exception in ZMQStream callback
Traceback (most recent call last):
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
   callback(*args, **kwargs)
 File "/home/user/jupyter-test/jupyter_client/jupyter_client/threaded.py", line 121, in _handle_recv
   msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
 File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
   self._check_running()
 File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
   raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:tornado.general:Uncaught exception in zmqstream callback
Traceback (most recent call last):
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 452, in _handle_events
   self._handle_recv()
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 481, in _handle_recv
   self._run_callback(callback, msg)
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
   callback(*args, **kwargs)
 File "/home/user/jupyter-test/jupyter_client/jupyter_client/threaded.py", line 121, in _handle_recv
   msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
 File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
   self._check_running()
 File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
   raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
ERROR:asyncio:Exception in callback BaseAsyncIOLoop._handle_events(18, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(18, 1)>
Traceback (most recent call last):
 File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
   self._context.run(self._callback, *self._args)
 File "/home/user/jupyter-test/lib/python3.9/site-packages/tornado/platform/asyncio.py", line 189, in _handle_events
   handler_func(fileobj, events)
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 452, in _handle_events
   self._handle_recv()
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 481, in _handle_recv
   self._run_callback(callback, msg)
 File "/home/user/jupyter-test/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 431, in _run_callback
   callback(*args, **kwargs)
 File "/home/user/jupyter-test/jupyter_client/jupyter_client/threaded.py", line 121, in _handle_recv
   msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
 File "/usr/lib/python3.9/asyncio/base_events.py", line 618, in run_until_complete
   self._check_running()
 File "/usr/lib/python3.9/asyncio/base_events.py", line 580, in _check_running
   raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
/usr/lib/python3.9/sre_parse.py:499: RuntimeWarning: coroutine 'get_msg' was never awaited
 sourceget = source.get
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

@ghost
Copy link
Author

ghost commented Jan 16, 2022

I've confirmed that this works with jupyter-client version 6.1.12

@ghost ghost changed the title Cannot run qtconsole with existing kernel Cannot run qtconsole with existing kernel in jupyter-client 7 Jan 16, 2022
@astromancer
Copy link

The ability to connect to an existing kernel is critical to my workflow. Hope this gets a fix soon.

@ccordoba12 ccordoba12 added this to the 5.3.2 milestone Jul 20, 2022
@ccordoba12 ccordoba12 modified the milestones: 5.3.2, 5.4.0 Aug 28, 2022
@ccordoba12 ccordoba12 removed this from the 5.4.0 milestone Oct 31, 2022
@bellecp
Copy link

bellecp commented Mar 11, 2023

I am running into the same issue as well. One quick fix is to

  1. launch the qtconsole (e.g., $ jupyter qtconsole &) which may open an undesired new kernel
  2. file -> new tab with existing kernel. Then, pick the desired kernel file
  3. close the tab of the undesired kernel opened in step 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants