---
title: "colored-traceback | pypx"
description: "Automatically color uncaught exception tracebacks"
canonical_url: "https://pypx.app/packages/colored-traceback"
meta:
  "og:description": "Automatically color uncaught exception tracebacks"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_colored-traceback%2Cversion_0.4.2%2Csummary_Automatically%2Bcolor%2Buncaught%2Bexception%2Btracebacks%2Clicense_ISC%2BLicense%2B(ISCL)%2Cp_Ii9wYWNrYWdlcy9jb2xvcmVkLXRyYWNlYmFjayI%2Cs_XJWQr0D1cL99rgRg.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "colored-traceback 0.4.2"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_colored-traceback%2Cversion_0.4.2%2Csummary_Automatically%2Bcolor%2Buncaught%2Bexception%2Btracebacks%2Clicense_ISC%2BLicense%2B(ISCL)%2Cp_Ii9wYWNrYWdlcy9jb2xvcmVkLXRyYWNlYmFjayI%2Cs_XJWQr0D1cL99rgRg.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **colored-traceback**

v0.4.2

Automatically color uncaught exception tracebacks

5 KBpy3-none-anyISC License (ISCL)2 deps Possibly Unmaintained

[** Diff **](https://pypx.app/packages/colored-traceback/diff)

`$ uv add colored-traceback`

# Colored Traceback

Automatically color Python's uncaught exception tracebacks.

This one's for anybody who's ever struggled to read python's stacktraces on the terminal. Something about the two-lines-per-frame approach really just makes them tough to scan visually.

Compare this:

```
Traceback (most recent call last):
  File "./workflowy.py", line 525, in <module>
    main()
  File "./workflowy.py", line 37, in main
    projects = cli.load_json(args, input_is_pipe)
  File "./workflowy.py", line 153, in load_json
    return json.load(sys.stdin)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 290, in load
    **kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
```

To this:

```python
Traceback (most recent call last):
  File "./workflowy.py", line 525, in <module>
    main()
  File "./workflowy.py", line 37, in main
    projects = cli.load_json(args, input_is_pipe)
  File "./workflowy.py", line 153, in load_json
    return json.load(sys.stdin)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 290, in load
    **kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
```

## Installation

Through pip:

```bash
pip install colored-traceback
```

Or directly:

```bash
git clone http://www.github.com/staticshock/colored-traceback.py
cd colored-traceback.py
pip install .
```

On Windows, which has no real support for ANSI escape sequences, this will also install `colorama`.

## Usage

Colored Traceback can be executed as a module:

```bash
python -m colored_traceback somefile.py
```

Colored Traceback also works well within a script or even directly in the interpreter REPL. Standard usage will color the output, unless it's being redirected to a pipe:

```python
import colored_traceback
colored_traceback.add_hook()
```

If want to retain color even when stderr is being piped, tack on an `always=True` argument:

```python
import colored_traceback
colored_traceback.add_hook(always=True)
```

There are also a couple of convenience imports, which get the footprint down to one line:

```python
# Same as add_hook()
import colored_traceback.auto

# Same as add_hook(always=True)
import colored_traceback.always
```

It goes without saying that you might want to catch `ImportError`, making the presence of the package optional:

```python
try:
    import colored_traceback.auto
except ImportError:
    pass
```

## **Details **

<dl>

<dt>Version</dt>
<dd>0.4.2</dd>

<dt>License</dt>
<dd>ISC License (ISCL)</dd>

<dt>Maintainer</dt>
<dd>Anton Backer &lt;olegov@gmail.com&gt;</dd></dl>

## **Links**

- [Source](https://www.github.com/staticshock/colored-traceback.py)
- [View on PyPI](https://pypi.org/project/colored-traceback/)

## **Maintainers **

- Anton Backer · [olegov@gmail.com](mailto:olegov@gmail.com)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/colored-traceback#webpage","@type":"WebPage","description":"Automatically color uncaught exception tracebacks","name":"colored-traceback","url":"https://pypx.app/packages/colored-traceback","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/colored-traceback"]}]},{"@id":"https://pypx.app/packages/colored-traceback#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"Automatically color uncaught exception tracebacks","license":"ISC License (ISCL)","name":"colored-traceback","softwareVersion":"0.4.2"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
