A CLI tool that explains Python errors in simple human language.
Project description
Error Translator
Error Translator is a powerful offline engine designed to parse raw Python tracebacks and translate them into crystal-clear explanations with immediately actionable fixes. Built with local-first development workflows in mind, 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-errorcommand. - Automatic Integration Mode: Inject the module via
import error_translator.autoto automatically overridesys.excepthookfor 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.jsonguarantees offline and privacy-first translations. - 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
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.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 /healthreturns service status.GET /serves the bundled web UI fromerror_translator/static/index.html.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file error_translator_cli_v2-1.1.4.tar.gz.
File metadata
- Download URL: error_translator_cli_v2-1.1.4.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e612125665078381389f9ff81dccf3ffda2cd5d7e28e6d5004544c370397bfbc
|
|
| MD5 |
e74b05d025d02e98f224d06117ce26a2
|
|
| BLAKE2b-256 |
e9122dc91c2b6a2922539a925103a490f5b3f543e87efea306750e0ba14f2faf
|
File details
Details for the file error_translator_cli_v2-1.1.4-py3-none-any.whl.
File metadata
- Download URL: error_translator_cli_v2-1.1.4-py3-none-any.whl
- Upload date:
- Size: 31.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
881d24fccfa1a4cb37313fc334a6fdcb89ef284a8f1d51c5c6a804be9f12f702
|
|
| MD5 |
10cdd7fe7f261abdec3e7c16aa7c5f78
|
|
| BLAKE2b-256 |
0ebfbd178df3adc66010ab3b601a6a0cfd164fa71b3d308382474e10b6cccbb6
|