albertz / background-zmq-ipython

Background ZMQ IPython/Jupyter kernel
BSD 2-Clause "Simplified" License
17 stars 4 forks source link

AttritubeError when using ipykernel >=6.0 #6

Closed Dalbasar closed 2 years ago

Dalbasar commented 2 years ago

Starting the background zmq ipython kernel fails when using ipykernel >=6.0:

import background_zmq_ipython
background_zmq_ipython.init_ipython_kernel()

To connect another client to this IPython kernel, use: jupyter console --existing 24012 \bzmqipython\lib\site-packages\traitlets\traitlets.py:1266: RuntimeWarning: Kernel only supports one shell stream. Additional streams will be ignored. c(event) IPython: Start kernel now. pid: 24012, thread: <Thread(IPython kernel, started daemon 22592)> debugpy_stream undefined, debugging will not be enabled ERROR:tornado.application:Exception in callback functools.partial(<bound method IPythonBackgroundKernelWrapper._start_kernel of <background_zmq_ipython.kernel.IPythonBackgroundKernelWrapper object at 0x000002539CADC4F0>>) Traceback (most recent call last): File "\bzmqipython\lib\site-packages\tornado\ioloop.py", line 741, in _run_callback ret = callback() File "\bzmqipython\lib\site-packages\background_zmq_ipython\kernel.py", line 284, in _start_kernel self._kernel.start() File "\bzmqipython\lib\site-packages\ipykernel\ipkernel.py", line 178, in start super(IPythonKernel, self).start() File "\bzmqipython\lib\site-packages\ipykernel\kernelbase.py", line 489, in start self.control_stream.on_recv(self.dispatch_control, copy=False) AttributeError: 'NoneType' object has no attribute 'on_recv'

Attemping to connect to the kernel with jupyter console --existing leads to an exception after hanging for a while:

Traceback (most recent call last): File "\bzmqipython\lib\site-packages\jupyter_console\ptshell.py", line 432, in init_kernel_info reply = self.client.get_shell_msg(timeout=1) File "\bzmqipython\lib\site-packages\jupyter_client\client.py", line 78, in get_shell_msg return self.shell_channel.get_msg(*args, **kwargs) File "\bzmqipython\lib\site-packages\jupyter_client\blocking\channels.py", line 54, in get_msg raise Empty _queue.Empty

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "\bzmqipython\Scripts\jupyter-console.EXE__main__.py", line 7, in File "\bzmqipython\lib\site-packages\jupyter_core\application.py", line 264, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, kwargs) File "\bzmqipython\lib\site-packages\traitlets\config\application.py", line 845, in launch_instance app.initialize(argv) File "\bzmqipython\lib\site-packages\traitlets\config\application.py", line 88, in inner return method(app, *args, *kwargs) File "\bzmqipython\lib\site-packages\jupyter_console\app.py", line 136, in initialize self.init_shell() File "\bzmqipython\lib\site-packages\jupyter_console\app.py", line 106, in init_shell self.shell = ZMQTerminalInteractiveShell.instance(parent=self, File "\bzmqipython\lib\site-packages\traitlets\config\configurable.py", line 540, in instance inst = cls(args, kwargs) File "\bzmqipython\lib\site-packages\jupyter_console\ptshell.py", line 350, in init self.init_kernel_info() File "\bzmqipython\lib\site-packages\jupyter_console\ptshell.py", line 435, in init_kernel_info raise RuntimeError("Kernel didn't respond to kernel_info_request") from e RuntimeError: Kernel didn't respond to kernel_info_request

It seems the IPythonKernel from ipykernel.ipkernel cannot be used with multiple shell_streams anymore in ipykernel 6.

I am using Python 3.9.9 on Windows 10 64bit and it works fine with ipykernel==5.5.6