I'm using IPython with iterm2 in macOS. I had never had issues before with the color scheme, but this time when an exception occurs, it highlights certain parts in a color combination that I find very hard to read. I've tried with different color setups in iterm and also adjusting highlighting_style
and colors
in the ipython_config.py
file, without much luck. I've seen there is an option to set specific colors highlighting_style_overrides
but I haven't been lucky finding the right pygments option for this.
See Position
below. This is the best contrast setup I've achieved, I still find hard it to read without focusing.
Here's an option you can drop in your ipython_config.py
to duck punch in a better background color:
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")
Verified to work with IPython
version 8.7.0
NOTE: Use Evan Grim's answer for a persistent config without touching package files.
There is an open issue regarding this: https://github.com/ipython/ipython/issues/13446
Here is the commit which introduced this change:
https://github.com/ipython/ipython/commit/3026c205487897f6874b2ff580fe0be33e36e033
To get the file path on your system, run the following:
import IPython, os
os.path.join(os.path.dirname(IPython.__file__), 'core/ultratb.py')
Finally, open the file and look for:
style = stack_data.style_with_executing_node(style, "bg:ansiyellow")
For the time being, you can manually patch it by changing bg:ansiyellow
to something that works best given your color scheme, e.g. bg:ansired
or bg:#ff0000
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With