gpt4 book ai didi

ipython - 将 IPython 控制台与 IPython 笔记本一起使用

转载 作者:行者123 更新时间:2023-12-02 05:25:34 26 4
gpt4 key购买 nike

在使用 IPython 笔记本时,我越来越希望笔记本上附有一个控制台,以进行交互式编程。我发现自己添加了几行来测试代码片段,然后删除它们,这就是很好的用法。在更糟糕的用法中,我会更改同一行中的命令,一遍又一遍地评估该行,完全更改该行的用途,直到我得到正确的结果,然后我 Ctrl-Z一直返回到原始单元格内容。

如果我可以在笔记本底部安装一个交互式解释器,那肯定会提高我的工作效率。我知道笔记本有一个内核,但我无法将新的 ipython 控制台附加到它。所以我的奇迹是:

  1. 是否有更有效的方法来使用笔记本?
  2. 假设没有,我如何将 ipython 控制台附加到笔记本内核?

谢谢!

最佳答案

只需在一个单元格中执行%qtconsole,它将启动附加到同一内核的 qtconsole。当然,您的内核需要是本地的。

你当然可以使用长方法:

In [1]: %connect_info
{
"stdin_port": 50845,
"ip": "127.0.0.1",
"control_port": 50846,
"hb_port": 50847,
"signature_scheme": "hmac-sha256",
"key": "c68e7f64-f764-4417-ba3c-613a5bf99095",
"shell_port": 50843,
"transport": "tcp",
"iopub_port": 50844
}

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-45781.json
or even just:
$> ipython <app> --existing
if this is the most recent IPython session you have started.

然后

 ipython qtconsole --existing kernel-45781.json

关于ipython - 将 IPython 控制台与 IPython 笔记本一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19479645/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com