How to get python terminal error in color?

I worked with iPython laptops for a while, and I really appreciated how the error output (if I made a writing / syntax error) was in color as follows: enter image description here

However, when I run the code from the terminal (because ipython still cannot do it), I do not get any color, for example: enter image description here

Of course, this may depend on the terminal / operating system, but I was curious if there is any simple package / plugin to make python error output in terminal color? or even what to look for (I am running zsh on ubuntu).

+4
source share
1 answer

API IPython, IPython.core.ultratb, IPython .

try:
    import IPython.core.ultratb
except ImportError:
    # No IPython. Use default exception printing.
    pass
else:
    import sys
    sys.excepthook = IPython.core.ultratb.ColorTB()

, IPython, , .

+5

All Articles