【问题标题】:How to change iPython error highlighting color如何更改 iPython 错误突出显示颜色
【发布时间】:2022-12-05 06:03:29
【问题描述】:

我在 macOS 中使用 iPython 和 iterm2。我以前从未遇到过配色方案问题,但这次发生异常时,它突出显示了我觉得很难阅读的颜色组合中的某些部分。我尝试在 iterm 中使用不同的颜色设置,并在 ipython_config.py 文件中调整 highlighting_stylecolors,但运气不佳。我看到有一个选项可以设置特定的颜色highlighting_style_overrides,但我没有幸运地为此找到正确的 pygments 选项。

请参阅下面的Position。这是我实现的最佳对比度设置,我仍然觉得不集中注意力很难阅读。

【问题讨论】:

  • 嗨,我面临着同样的问题。你的问题解决了吗?
  • 不,我还没有找到解决方案

标签: ipython


【解决方案1】:

关于这个有一个未解决的问题:https://github.com/ipython/ipython/issues/13446


这是引入此更改的提交:

https://github.com/ipython/ipython/commit/3026c205487897f6874b2ff580fe0be33e36e033

要获取系统上的文件路径,请运行以下命令:

import IPython, os
os.path.join(os.path.dirname(IPython.__file__), 'core/ultratb.py')

最后,打开文件并查找:

style = stack_data.style_with_executing_node(style, "bg:ansiyellow")

目前,您可以通过将 bg:ansiyellow 更改为最适合您的配色方案的内容来手动修补它,例如bg:ansiredbg:#ff0000

【讨论】:

    【解决方案2】:

    这是一个选项,您可以将 ipython_config.py 放入更好的背景颜色中以躲避打孔:

    try:
        from IPython.core import ultratb
        ultratb.VerboseTB._tb_highlight = "bg:ansired"
    except Exception:
        print("Error patching background color for tracebacks, they'll be the ugly default instead")
    

    已验证可与 IPython 版本 8.7.0 一起使用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-12
      • 2012-03-27
      • 1970-01-01
      • 2011-02-02
      相关资源
      最近更新 更多