gpt4 book ai didi

python - 如何禁用 jupyter notebook 历史记录

转载 作者:太空狗 更新时间:2023-10-29 21:09:28 25 4
gpt4 key购买 nike

我正在使用 Jupyter Notebook 在 Python 2 中编写代码。我将其调用为:

c:\python27\scripts\jupyter-notebook --no-browser

同时我使用 IPython 控制台,启动时:

c:\python27\scripts\ipython

我遇到的问题是 Jupyter 历史记录被保存并与 IPython 历史记录混合在一起。我根本不想要 Jupyter Notebook 历史记录-有没有办法在保留 IPython** 历史记录的同时禁用它?

平台:win32

更新:

我尝试使用建议的设置摘要方法。但是当我在配置中输入“c.Session.digest_history_size = 0”时,重新启动笔记本,在某个单元格中写入“print 'next test'”,重新启动单独的 IPython,按下后我得到的第一件事是“print 'next test' '”。

我怎样才能摆脱它?

最佳答案

参见 this Jupyter issue on Github对于这个解决方案的起源。

Introduction to IPython Configuration讨论了使用位于 ~/.ipython/profile_default/ 主目录中的配置脚本。这是 default 配置文件的相关目录,如果创建其他配置文件,则会出现其他类似的目录。

在该目录中,可以包含文件 ipython_config.py,它将在每次使用 IPython 时运行。但是,文件 ipython_kernel_config.py 将在调用 IPython 内核时运行,而不是在调用 IPython 解释器本身时运行。可以通过执行 ipython kernel --debug 来测试这一点。

Jupyter 笔记本使用这种内核调用方式。因此,在目录 ~/.ipython/profile_default/ 中包含脚本 ipython_kernel_config.py(假设 default 配置文件),其中包含以下行:

# Configuration file for ipython-kernel.

c = get_config()

c.HistoryManager.enabled = False

在使用那种内核调用风格时应该完全禁用历史管理器。因此,不应从 Jupyter 调用中填充命令历史记录。

顺便说一句,同一目录中的文件 history.sqlite 是命令历史记录。因此,删除它或将其移动到不同的文件名将清除命令历史缓冲区。

关于python - 如何禁用 jupyter notebook 历史记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41296920/

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