ipython: Highlight colour for errors makes them unreadable

Screenshot 2022-01-30 at 21 35 52

╰─ ipython
Python 3.9.2 (default, Mar 18 2021, 20:48:06)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.0.1 -- An enhanced Interactive Python. Type '?' for help.

I’m on macos, iTerm2

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 17 (5 by maintainers)

Most upvoted comments

@Carreau The issue you linked to has been locked. Are there any documented workarounds for this? The conversation in the linked issue talks about perhaps using bold, underlined text rather than a background color, but don’t include instructions.

This still appears to be an issue in iPython 8.4:

image

(Alacritty with Duskfox theme)

You can also create an ipython startup script and place it .ipyhon/profile_default/startup/001.py. I’m not sure if the name of the file matters, but that was how I saw in some docs.

# 001.py
import IPython
from IPython.core import ultratb

ultratb.VerboseTB._tb_highlight = 'bg:ansired'

ipython = IPython.get_ipython()
if ipython is not None:
    ipython_version = IPython.__version__
    major_version = int(ipython_version.split('.')[0])
    minor_version = int(ipython_version.split('.')[1])

    if major_version < 8 or (major_version == 8 and minor_version < 1):
        ipython.magic("load_ext autoreload")
        ipython.magic("autoreload 2")
    else:
        ipython.run_line_magic(magic_name="load_ext", line="autoreload")
        ipython.run_line_magic(magic_name="autoreload", line="2")

    print("Autoreload enabled.")
else:
    print("Autoreload not enabled.")

Still experiencing this in ipython 8.11.0, I have to use the workaround described in the above comment

image

There is a temp fix suggested here that works for me; https://stackoverflow.com/a/74681224

Duplicate #13446