本文介绍了IPython Notebook:如何连接到现有内核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够通过以下方式将两个ipython console会话连接到一个内核:

I am able to connect two ipython console session to one kernel by:

$ ipython console
In [1]: %connect_info
{
   ... Content of JSON with info for connecting ...
}

Paste the above JSON into a file, and connect with:
    $> ipython <app> --existing <file>
or, if you are local, you can connect with just:
    $> ipython <app> --existing kernel-43204.json
or even just:
    $> ipython <app> --existing
    if this is the most recent IPython session you have started.

因此,我可以再次用控制台替换<app>

And accordingly I can substitute the <app> by console again

$ ipython console --existing kernel-43204.json

但是,我想与ipython Notebook共享我的内核,以便可以可视化我的数据.我尝试并失败了:

However, I want to share my kernel with ipython notebook so I can visualize my data. I tried and failed with:

$ ipython notebook --existing kernel-43204.json
[C 13:35:01.025 NotebookApp] Unrecognized flag: '--existing'

有人建议我如何工作并在ipython consoleipython notebook之间切换吗?

Any suggestion how I can work and switch between ipython console and ipython notebook?

推荐答案

笔记本电脑没有UI或API可以做到这一点,为了简化代码,我们假设笔记本电脑是拥有并启动内核的笔记本电脑.您将必须编写自己的KernelManager子类并将IPython配置为使用它(如果需要,可以编写一些UI代码,如果要易于使用),以便能够选择一个已经存在的内核.

There is no UI, nor API to do that with the notebook, there is an assumption for code simplicity that the notebook is the one that own and start the kernel. You will have to write your own KernelManager subclass and configure IPython to use it (+ write a bit of UI code, if you want it easy to use), for you to be able to select an already existing kernel.

这篇关于IPython Notebook:如何连接到现有内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 02:24
查看更多