python - 如何从 Python 脚本管理多个 IPython/Jupyter 内核并与之通信?

标签 python ipython ipython-notebook jupyter

我想模仿笔记本服务器的功能,而不是从中央逻辑主体(即我自己的 Python 脚本)协调不同 IPython/Jupyter 内核的创建/管理。

例如,我想:

  • 定义一个抽象命令,例如“添加(x,y)”
  • 将抽象命令传达给多个内核,例如IPython 内核和 Scala 内核
  • 让每个内核随心所欲地执行命令
  • 将每个内核的结果返回给中央逻辑体

谁能指出我如何以编程方式启动/停止/与多个 IPython/Jupyter 内核通信的方向?

最佳答案

KernelManager 处理启动和停止单个内核,还有一个 MultiKernelManager 来协调多个内核。

然后您可以使用 .client() 方法获取处理与内核通信的 KernelClient 实例:

有关如何与内核通信的详细信息,请参阅 message spec docs .其中一些由 KernelClient 抽象出来,但您可能需要了解其中的一些内容。

关于python - 如何从 Python 脚本管理多个 IPython/Jupyter 内核并与之通信?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29949881/

相关文章:

python - 使用基于函数的 View 获取 pk_id

latex - Ipython Notebook 中有没有办法内联显示 LaTeX 文件?

python - IPython 内联!爆炸 shell 命令

python - 提高绩效以返回值(value)

Python XlsxWriter 图表 : x-axis value labels angle orientation

python - IPython/jupyter 笔记本中的自动更新模块

python - 将用于 Python 3 内核的 IPython 3 也更改为用于集群的 python2

port - 更改 iPython 笔记本服务器/Jupyter 的默认端口

python koan - 将这两个衬里简化为一个

python - 合并两个数据帧而不重复pandas