pip install IPython
put early in your code (e.g. main.py)
# source: https://stackoverflow.com/a/52797444/227260
import sys
from IPython.core import ultratb
# the StackOverflow example showed this, but these values were defaults when I inspected.
# sys.excepthook = ultratb.FormattedTB(color_scheme='Linux', call_pdb=False)
# This works for me.
sys.excepthook = ultratb.FormattedTB()
# Verbose output
# sys.excepthook = ultratb.VerboseTB()
- NoColor: allows all of this module to be used in any terminal (the color escapes are just dummy blank strings).
- Linux: is meant to look good in a terminal like the Linux console (black or very dark background).
- LightBG: similar to Linux but swaps dark/light colors to be more readable in light background terminals.
- Neutral: a neutral color scheme that should be readable on both light and dark background
https://ipython.readthedocs.io/en/stable/api/generated/IPython.core.ultratb.html