0

我正在尝试使用 jupyter_client 包通过 python shell 与正在运行的 ipython 内核进行交互。

我正在运行内核,连接文件(例如“kernel-7772.json”)位于 %APPDATA%\jupyter\runtime 中。

我运行的代码如下:

import jupyter_client
cf = jupyter_client.find_connection_file('7772')
km = jupyter_client.KernelClient(connection_file = cf)
km.load_connection_file()
km.start_channels()

然后我得到错误TypeError: ChannelABC() takes no arguments

(完整追溯:

File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\client.py", line 101 in start_channels
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\client.py", line 143 in shell_channel
    socket, self.session, self.ioloop

)

我也尝试过使用BlockingKernelClient,它完全没有问题。但是,我更喜欢使用非阻塞KernelClient. 难道我做错了什么?有错误KernelClient吗?

我的 jupyter_client 版本是 5.3.1,我使用的是 python 3.7.3。

4

1 回答 1

0

KernelClient是一个抽象类。解决方案是AsyncKernelClient改用。

import jupyter_client
cf = jupyter_client.find_connection_file('7772')
km = jupyter_client.AsyncKernelClient(connection_file = cf)
km.load_connection_file()
km.start_channels()
于 2021-01-01T07:15:52.337 回答