Skip to main content

Offline Python traceback translator and error explainer CLI that converts exceptions into clear explanations and actionable fixes.

Project description

Error Translator

PyPI Version Python 3.9+ GitHub Stars PyPI Downloads License Build Status

Error Translator is an offline Python traceback translator and exception explainer that converts raw errors into crystal-clear explanations and immediately actionable fixes. Built for local-first development workflows, it supports direct CLI usage, an automatic import hook, a programmatic Python API, and a FastAPI integration.

If this project saves you debugging time, please consider starring it on GitHub: https://github.com/gourabanandad/error-translator-cli-v2

Why Developers Like It

  • Fast Feedback Loop: Turn stack traces into direct next actions in seconds.
  • Works Offline: No telemetry dependency for core translation behavior.
  • Beginner-Friendly Output: Explanations are clear enough for learners, practical enough for teams.
  • Multiple Entry Points: CLI, import hook, Python API, and FastAPI all share one deterministic engine.

Key Features

  • CLI-First Architecture: Seamlessly process scripts, direct error strings, or piped logs via the explain-error command.
  • Professional Rich Terminal UI: Clean panels, syntax-highlighted code context, structured sections, and improved readability for day-to-day debugging.
  • Automatic Integration Mode: Inject the module via import error_translator.auto to automatically override sys.excepthook for graceful, translated crash reporting.
  • Extensible API Surfaces: Integrate natively within Python or expose the core engine over HTTP via the included FastAPI server.
  • Deterministic Rules Engine: High-performance, regex-based matching powered by rules.json guarantees offline and privacy-first translations.
  • Optional Native Acceleration: A C extension matcher (fast_matcher) can accelerate rule scanning, with automatic fallback to pure Python when unavailable.
  • Optional AST Insight Hooks: Registered handlers can append targeted hints (ast_insight) for selected error types.

Installation

Python requirement: 3.9 or newer.

Install the latest stable release directly from PyPI:

pip install error-translator-cli-v2

Verify the installation:

explain-error --version

Usage Guide

1. Command-Line Interface (CLI)

Run a Python script and catch any unhandled exceptions:

explain-error run script.py

Provide an error string directly:

explain-error "NameError: name 'usr_count' is not defined"

Pipe system or Docker logs into the engine:

cat error.log | explain-error

Emit structured JSON for scripting and automation:

explain-error --json "NameError: name 'x' is not defined"
# {"explanation": "...", "fix": "...", "matched_error": "...", "file": "...", "line": "...", "code": "...", "ast_insight": null}

Show an about screen with project metadata and quick usage examples:

explain-error --about

The --json flag works with every input mode (run <script>, raw string, piped log).

2. Automatic Import Hook

Catch and translate unhandled exceptions globally by importing the module:

import error_translator.auto

def main():
    # This TypeError will automatically trigger the error translator
    total = "Users: " + 42

if __name__ == "__main__":
    main()

3. FastAPI Service

Start the built-in HTTP server for remote translation services:

uvicorn error_translator.api.server:app --host 127.0.0.1 --port 8000 --reload

Submit a traceback payload via the exposed REST API:

curl -X POST http://127.0.0.1:8000/translate \
  -H "Content-Type: application/json" \
  -d "{\"traceback_setting\":\"Traceback (most recent call last):\\n  File 'app.py', line 14, in <module>\\n    total = 'Users: ' + 42\\nTypeError: can only concatenate str (not 'int') to str\"}"

Additional endpoints:

  • GET /health returns service status.
  • GET / serves the bundled web UI from error_translator/api/static/index.html.

4. Optional C Extension Build

The translation engine automatically attempts to import error_translator.fast_matcher. If it is not built or not available on the platform, Error Translator falls back to the pure Python regex loop with no behavior change.

Build the extension in-place from the repository root:

python setup_ext.py build_ext --inplace

This step is optional and intended for local performance optimization.

Documentation

Detailed documentation is located in the docs/ directory:

  • Real-World Examples: Practical demonstrations comparing raw tracebacks with their translated counterparts.
  • Architecture & Internals: Comprehensive teardown of the regex engine, AST integration, and internal design philosophy.
  • Contributing Guidelines: Standards, PR checklists, and instructions for utilizing our AI-Powered Rule Builder.

Maintainers

This project is actively developed and maintained by Gourabananda Datta alongside our open-source contributors.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

error_translator_cli_v2-3.0.4.dev5.tar.gz (45.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

error_translator_cli_v2-3.0.4.dev5-cp313-cp313-win_amd64.whl (50.0 kB view details)

Uploaded CPython 3.13Windows x86-64

error_translator_cli_v2-3.0.4.dev5-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (54.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

error_translator_cli_v2-3.0.4.dev5-cp313-cp313-macosx_11_0_arm64.whl (47.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

error_translator_cli_v2-3.0.4.dev5-cp313-cp313-macosx_10_13_x86_64.whl (47.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

error_translator_cli_v2-3.0.4.dev5-cp312-cp312-win_amd64.whl (50.0 kB view details)

Uploaded CPython 3.12Windows x86-64

error_translator_cli_v2-3.0.4.dev5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (54.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

error_translator_cli_v2-3.0.4.dev5-cp312-cp312-macosx_11_0_arm64.whl (47.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

error_translator_cli_v2-3.0.4.dev5-cp312-cp312-macosx_10_13_x86_64.whl (47.1 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

error_translator_cli_v2-3.0.4.dev5-cp311-cp311-win_amd64.whl (50.0 kB view details)

Uploaded CPython 3.11Windows x86-64

error_translator_cli_v2-3.0.4.dev5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (54.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

error_translator_cli_v2-3.0.4.dev5-cp311-cp311-macosx_11_0_arm64.whl (47.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

error_translator_cli_v2-3.0.4.dev5-cp311-cp311-macosx_10_9_x86_64.whl (47.1 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

error_translator_cli_v2-3.0.4.dev5-cp310-cp310-win_amd64.whl (50.0 kB view details)

Uploaded CPython 3.10Windows x86-64

error_translator_cli_v2-3.0.4.dev5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (54.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

error_translator_cli_v2-3.0.4.dev5-cp310-cp310-macosx_11_0_arm64.whl (47.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

error_translator_cli_v2-3.0.4.dev5-cp310-cp310-macosx_10_9_x86_64.whl (47.1 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

error_translator_cli_v2-3.0.4.dev5-cp39-cp39-win_amd64.whl (50.0 kB view details)

Uploaded CPython 3.9Windows x86-64

error_translator_cli_v2-3.0.4.dev5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (53.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

error_translator_cli_v2-3.0.4.dev5-cp39-cp39-macosx_11_0_arm64.whl (47.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

error_translator_cli_v2-3.0.4.dev5-cp39-cp39-macosx_10_9_x86_64.whl (47.1 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file error_translator_cli_v2-3.0.4.dev5.tar.gz.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5.tar.gz
Algorithm Hash digest
SHA256 004e3e34a6ffad93aa477f913a1efd39797bcbe84072cc34ddb8b930d545f719
MD5 16bf84df8b960af62506702e947582e5
BLAKE2b-256 341ddba7044aa9577149c0669ab11ff82ded441d67329cd41bff453b0f32873b

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0aff91e25b4f13570c90e2660b92eef9a2d1ff7fa8ad73af39fe0644e9ac077e
MD5 3206d8591323278a21243e9164bd79d2
BLAKE2b-256 c4133f173e5aad1d8854ba5848a309961c08e6e75b54145d43636b3e7ff5706b

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e9ebdbf623379150e5d8c906282c5a8ecaf8d8d9fdc059fc22256e5386b145d9
MD5 dd8b1f4cb0288f4c13f5076060c082c8
BLAKE2b-256 7457f835c84466c30b9cdc8a45fbafe179c7e947ec928d57ae3e2cebf006e6d0

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ef5f90177bfee0909ed209ab113fc785a3c18ef169d4859fcd01063bc3a68bd5
MD5 f1521ae945af46603de65bb3852e1847
BLAKE2b-256 79d6a11ed979e9c82821ecbb45c0a8aab98e4560d113638c98632428fe850e9f

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f70c3fab83db36d747f33f849530a05f1350964a6305ee09a3d86c221d7b554d
MD5 29ee8527e2f289e36fb033a5cbece70d
BLAKE2b-256 17624c55bf3cdf82ac393ae78ca627da02d5db7de884773c733a71b6cdc18804

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 91eb51b29b085d0a6291199c588791d98dff64a7b68829655cd6ab2cf000cb4b
MD5 e2d8353017ef058b64927dbc883e6f30
BLAKE2b-256 318e63d673ee3fefca2f881a26d5472aef535420fafccc58d059d17a5bc61799

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 68e2fcb2d5aedfafb226885e4180b1a12b2c126a84db9258261df1092812a6bf
MD5 288de1a7d26243836481450600c45c67
BLAKE2b-256 9dc4b44e6c5f1f8b8f6a1f0424bcf73e610e754ead024be734117b39deb60089

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56e493dcf2a69d1fbd59d5ff3affb697b3612ce5f2fb8634d5e2c68f4285b939
MD5 8c2708cebbc9c2246401d7a0e5d40edd
BLAKE2b-256 21dc6d2f6d153ef56341666053ecebf7ce0ef9b7476499abd050d2e7f31d4eb5

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cc0a3ce16fa8baaed46cbe4693dd4536ce5183590c658cae172ed9eaf37fe01c
MD5 6649b8d185148d21a344526fc7cf5d57
BLAKE2b-256 c551c27eb8d6e6f89be301b346fac923bc28ebad6d8328ccb2ce77a3275ab6d3

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 31b447b6aa55634fd6fcad7aba4ab1ed4c003dbd25a61422aad56aefb68eecaf
MD5 cba3e7ed724157b65e189ce2ba8cddda
BLAKE2b-256 1beb81f8c15eba25a55cfe94d31ca3389ec1d84297e8c989237be981f5d645a3

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e082eaf6d094487f61dc2d086a2b856794dfc897e1825c96f7889d84d426236e
MD5 b0d809b82ed163a6768a9f89bba32959
BLAKE2b-256 e042d9614ba3192d1d82b0d97b88001a3fe643f6dd8f01585927d431c6b71aea

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2548ae1157ab4aa09aaccc6e19beb80f7ec293b225a14303feae2a92d2dbb5a9
MD5 0c6fedefe33dd66a6de589321d1a4648
BLAKE2b-256 a1f0c0a7e42d4488cc1fa949a29d20c3f0b604799b9bb61ee20341e6b060caa6

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c381cefa0e26dc6dfef507837a1a5f709d93b5d11be7db1f30aa4449552c2fb0
MD5 44ff297ad99fcb3f7711a6ea8066017f
BLAKE2b-256 ca043d23047fab75f84ce3973195d2a66ac86ae85e9855eef4b466ce5eb4d214

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a9156ecc23bb8b9d21eeb2818cd2f2b8c31739e66ce61602a873a3aca446f7a2
MD5 45371a0e39f179dd5b5abc2538e8581d
BLAKE2b-256 a7c3207291b38709de1e9322db2b5a067884f4bb19dee8b605cba2328b1335f0

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 73117ac1c6425b3fae7122dd032996372e443c3fe27c5fe13bac2596a2033e6e
MD5 edade081d3048aba6a57844b9a225dd0
BLAKE2b-256 5fb4fdcb569f57d1383ec6ba9953396ba827dc5cf5354860dace92cc508c60fb

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ba49fafacfe26b8c545935149ac661b9b58c5b6a63517aa8e6df6eef4d4eedc6
MD5 7daeb372a75662afa3aa052e0cd1d9ec
BLAKE2b-256 b39319fbb424954170bb3c6c530c3ffa367b7d5fa6d413cc163a223442b34108

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7a5c0b2f24b1e5862aa3446adf7dc77fd6124f4ce5bbab626c1e5d986d7a201d
MD5 833e5b1fac64a3bd2ccecdf21544c3bc
BLAKE2b-256 e96c9191c26c5e35897b84bd808e5473a8ca8a7b105f39146031ebc50f2f7ad8

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f0126e0e6a5921d92fc0a9822d04dc29c61c76c8b01fc640e7f659917e633301
MD5 833f2d7b048dd1dc2a4faf99c6d0517a
BLAKE2b-256 d292eead19d923a7e26f8d6d90944d1cf4aa76e8689cc2ee12f8cf7cf4adb6c2

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54181ac0facdb9193d978ddcd32703bc27cac7b32004f9724b0656258d534f8d
MD5 8011efbab95c2a2e905734423cc35642
BLAKE2b-256 6da316cc38d7f48853a19b202d09ba59cff7de02d3f51a275e39aefa7e6488e7

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ab13166e6907b689543e5f348c3f66b4e8d012c435a30194012299107755ca1
MD5 3f14c41464e58372c42053807259eef1
BLAKE2b-256 e909a16d1c0d21a45bd4f38c58cb00735fd97a76b6218d2d24f2ceec9e058ae6

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-3.0.4.dev5-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-3.0.4.dev5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a95488407b989b0c6acdaae36ac9f7fe94f28f3466930ea6b0ccb6f18b18a9ad
MD5 22e722dccf3c6d7a465a80bea0e0892c
BLAKE2b-256 3ff243ebcae2706ef3ee3737c81c465325f3374e675267b85d7cb41760e54d79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page