Skip to main content

AI-powered Python debugger that explains errors in plain English with practical fixes

Project description

๐Ÿ› AI-DBUG

An AI-powered Python debugger that explains errors in plain English with suggested fixes.

Stop wasting time deciphering cryptic error messages! AI-DBUG translates Python errors into clear, understandable explanations with practical solutions.

โœจ Features

  • ๐ŸŽฏ Automatic Error Capture - Hooks into Python's exception system
  • ๐Ÿ’ก Plain English Explanations - No more cryptic error messages
  • ๐Ÿ”ง Practical Fix Suggestions - Step-by-step solutions for 70+ error types
  • ๐ŸŽจ Beautiful Output - Colored, formatted error messages
  • ๐ŸŒ Cross-Platform - Works on Windows, macOS, and Linux
  • ๐Ÿ–ฅ๏ธ IDE Compatible - VS Code, PyCharm, Jupyter, and all terminals
  • ๐Ÿ“š Extensive Knowledge Base - Covers almost all Python error types
  • ๐Ÿ”Œ One-Line Setup - Get started in seconds

๐ŸŒ Platform Support

Platform Emojis Colors Status
๐ŸชŸ Windows Terminal โœ… โœ… โœ… Perfect
๐ŸชŸ Windows CMD/PowerShell ASCII โœ… โœ… Good
๐Ÿ–ฅ๏ธ VS Code โœ… โœ… โœ… Perfect
๐ŸŽ macOS Terminal โœ… โœ… โœ… Perfect
๐Ÿง Linux Terminal โœ… โœ… โœ… Perfect
๐Ÿ’ป PyCharm โœ… โœ… โœ… Perfect
๐Ÿ““ Jupyter โœ… โœ… โœ… Perfect

๐Ÿ“ฆ Installation

pip install ai-dbug

For colored output (recommended):

pip install ai-dbug[color]

For all features:

pip install ai-dbug[full]

๐Ÿš€ Quick Start

Basic Usage

import ai_dbug

# Enable AI debugging - that's it!
ai_dbug.enable_ai_debugging()

# Your code here
result = 5 + "10"  # TypeError with helpful explanation!

Output Example

======================================================================
                          ๐Ÿ› AI-DBUG: Error Analysis
======================================================================

โŒ Error
TypeError: can only concatenate str (not "int") to str

๐Ÿ“ Location
File: example.py, Line: 7, Function: <module>
Code: result = 5 + "10"

๐Ÿ’ก What Happened?
You're trying to perform an operation between incompatible types
(e.g., adding a number and a string).

๐Ÿ”ง How to Fix
Convert one type to match the other. For example:
str(number) + string or int(string) + number.

๐Ÿ“ Example
age = 25
print('Age: ' + str(age))  # Convert int to str
# or
result = int('10') + 5     # Convert str to int

๐Ÿ“– Usage Examples

Method 1: Global Debugging

import ai_dbug

ai_dbug.enable_ai_debugging()

# All errors in your script will be explained
data = {'name': 'Alice'}
print(data['age'])  # KeyError with AI explanation

Method 2: Context Manager

from ai_dbug import debug_context

# Only debug specific code blocks
with debug_context():
    result = 10 / 0  # ZeroDivisionError with explanation

Method 3: Multiple Errors

from ai_dbug import debug_multiple

# Catch and explain multiple errors without stopping
with debug_multiple() as handler:
    with handler:
        x = 5 + "10"  # Error 1

    with handler:
        data['missing']  # Error 2

    with handler:
        10 / 0  # Error 3

# Output: "3 errors caught and explained"

Method 4: Manual Analysis

from ai_dbug import ErrorAnalyzer, ErrorFormatter
import sys

analyzer = ErrorAnalyzer()
formatter = ErrorFormatter()

try:
    problematic_code()
except Exception:
    exc_type, exc_value, exc_tb = sys.exc_info()
    analysis = analyzer.analyze_exception(exc_type, exc_value, exc_tb)
    formatter.format_error(analysis)

๐Ÿ“š Supported Error Types (70+)

Type Errors (10+ variations)
  • Adding incompatible types
  • NoneType errors
  • Calling non-callable objects
  • Type conversion issues
  • Subscriptable type errors
  • And more...
Value Errors (7+ variations)
  • Invalid int/float conversions
  • Unpacking errors
  • Math domain errors
  • Empty ranges
  • Substring not found
  • And more...
Key/Attribute Errors (5+ variations)
  • Missing dictionary keys
  • Undefined attributes
  • Module attribute errors
  • NoneType attribute access
  • And more...
Index Errors
  • List index out of range
  • String index out of range
  • Tuple index out of range
Import Errors (4+ variations)
  • ModuleNotFoundError
  • ImportError
  • Cannot import name
  • No module named
Name Errors
  • Undefined variables
  • Global name errors
  • UnboundLocalError
Indentation Errors
  • Inconsistent indentation
  • Expected indented block
  • Tab/space mixing
Syntax Errors (6+ variations)
  • Invalid syntax
  • EOF while parsing
  • Invalid characters
  • Keyword argument issues
  • And more...
File Errors (5+ variations)
  • FileNotFoundError
  • PermissionError
  • IsADirectoryError
  • Unicode encoding errors
  • And more...
Math Errors
  • ZeroDivisionError
  • OverflowError
  • FloatingPointError
Async/Await Errors (4+ variations)
  • Event loop issues
  • Coroutine errors
  • await outside async
  • And more...
Other Common Errors
  • RecursionError
  • AssertionError
  • MemoryError
  • OSError
  • ConnectionError
  • TimeoutError
  • KeyboardInterrupt
  • JSON/Database errors
  • Pandas errors
  • Threading errors
  • And many more...

โš™๏ธ Configuration

Hide Original Traceback

import ai_dbug

# Show only AI-DBUG output (cleaner!)
ai_dbug.enable_ai_debugging(
    use_color=True,
    show_original_traceback=False  # Default
)

Disable Colors

# Maximum compatibility mode
ai_dbug.enable_ai_debugging(use_color=False)

Temporarily Disable

import ai_dbug

ai_dbug.enable_ai_debugging()
# ... your code ...
ai_dbug.disable_ai_debugging()

๐ŸŽจ Output Formats

AI-DBUG automatically adapts to your environment:

Modern Terminals

  • Windows Terminal, macOS, Linux
  • Beautiful panels with emojis: ๐Ÿ› โŒ ๐Ÿ’ก ๐Ÿ”ง ๐Ÿ“ ๐Ÿ“
  • Full color support

Legacy Consoles

  • Windows CMD, PowerShell 5
  • ASCII fallback: [!] [X] [@] [?] [+] [~]
  • Color support maintained

Plain Text Mode

  • No colors, pure ASCII
  • Maximum compatibility

๐Ÿงช Running Tests

# Install with dev dependencies
pip install ai-dbug[dev]

# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=ai_dbug --cov-report=html

# View coverage report
open htmlcov/index.html

๐ŸŽฏ Real-World Examples

Example 1: Beginner-Friendly TypeError

Before AI-DBUG:

TypeError: unsupported operand type(s) for +: 'int' and 'str'

๐Ÿ˜• What does this mean?

With AI-DBUG:

๐Ÿ’ก What Happened?
You're trying to add a number and text together. Python doesn't know
if you want math (5 + 10) or joining text ("5" + "10").

๐Ÿ”ง How to Fix
Convert both to the same type:
- For math: int("10") + 5 = 15
- For text: str(5) + "10" = "510"

๐Ÿ˜Š Clear and helpful!

Example 2: Dictionary KeyError

Before AI-DBUG:

KeyError: 'phone'

With AI-DBUG:

๐Ÿ’ก What Happened?
You're trying to access a dictionary key 'phone' that doesn't exist.

๐Ÿ”ง How to Fix
1. Check if key exists first:
   if 'phone' in user_data:
       phone = user_data['phone']

2. Use .get() with a default:
   phone = user_data.get('phone', 'Not provided')

Example 3: File Operations

Before AI-DBUG:

FileNotFoundError: [Errno 2] No such file or directory: 'data.txt'

With AI-DBUG:

๐Ÿ’ก What Happened?
Python can't find the file 'data.txt'. It's looking in:
/home/user/project/

๐Ÿ”ง How to Fix
1. Check the file exists:
   import os
   if os.path.exists('data.txt'):
       with open('data.txt') as f:
           content = f.read()

2. Use absolute path:
   filepath = '/full/path/to/data.txt'

3. Check current directory:
   print(os.getcwd())

๐ŸŒ Platform-Specific Notes

๐ŸชŸ Windows

  • Best Experience: Use Windows Terminal (free from Microsoft Store)
  • VS Code: Works perfectly with both integrated terminal and Run button
  • Legacy Console: Automatic ASCII fallback with colors

๐ŸŽ macOS

  • Works perfectly out of the box
  • Full emoji and color support
  • All terminals supported

๐Ÿง Linux

  • Works on all distributions
  • Full emoji and color support
  • Install emoji fonts if needed: sudo apt install fonts-noto-color-emoji

๐Ÿ—๏ธ Project Structure

ai-dbug/
โ”œโ”€โ”€ ai_dbug/
โ”‚   โ”œโ”€โ”€ __init__.py          # Package exports
โ”‚   โ”œโ”€โ”€ core.py              # Main debugger
โ”‚   โ”œโ”€โ”€ knowledge_base.py    # 70+ error explanations
โ”‚   โ”œโ”€โ”€ formatter.py         # Cross-platform output
โ”‚   โ””โ”€โ”€ analyzer.py          # Error analysis
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ test_ai_dbug.py      # Test suite
โ”œโ”€โ”€ README.md                # This file
โ”œโ”€โ”€ LICENSE                  # MIT License
โ”œโ”€โ”€ pyproject.toml           # Package config
โ”œโ”€โ”€ setup.py                 # Setup script
โ””โ”€โ”€ .gitignore               # Git ignore rules

๐Ÿค Contributing

We love contributions! Here's how you can help:

Add New Error Explanations

  1. Fork the repository
  2. Edit ai_dbug/knowledge_base.py
  3. Add your error with explanation, fix, and example
  4. Add tests in tests/test_ai_dbug.py
  5. Submit a pull request

Example:

ERROR_KNOWLEDGE_BASE = {
    "YourError: pattern here": {
        "explanation": "Clear explanation in plain English",
        "fix": "Step-by-step solution",
        "example": "# Working code example\ncode_here()"
    }
}

Report Issues

Found a bug or have a suggestion? Open an issue

Improve Documentation

Documentation improvements are always welcome!

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Inspired by the need for beginner-friendly error messages
  • Built with love for the Python community
  • Uses rich for beautiful output
  • Uses colorama for Windows colors

๐Ÿ“ž Support & Community

๐Ÿ—บ๏ธ Roadmap

  • Cross-platform compatibility (Windows, macOS, Linux)
  • 70+ error types with explanations
  • IDE compatibility (VS Code, PyCharm, Jupyter)
  • Multiple error catching
  • VS Code extension
  • PyCharm plugin
  • Web dashboard for error analytics
  • AI-powered custom error suggestions
  • Community solution database
  • Multi-language support (Spanish, French, German, etc.)
  • Integration with CI/CD pipelines

๐ŸŽ“ Educational Use

Perfect for:

  • ๐Ÿ‘จโ€๐ŸŽ“ Teaching Python to beginners
  • ๐Ÿ“š Coding bootcamps and courses
  • ๐Ÿซ Computer science classes
  • ๐Ÿ“– Self-learners and tutorials

๐Ÿ“ˆ Statistics

  • 70+ Error Types covered
  • 4 Usage Modes (global, context, multiple, manual)
  • 7+ Platforms supported
  • 0 Configuration required
  • 100% Python - no external services

๐Ÿ’ก Why AI-DBUG?

Before AI-DBUG ๐Ÿ˜ž

Traceback (most recent call last):
  File "script.py", line 42, in <module>
    process_data(items)
  File "script.py", line 15, in process_data
    return [item.upper() for item in items]
  File "script.py", line 15, in <listcomp>
    return [item.upper() for item in items]
AttributeError: 'int' object has no attribute 'upper'

Spends 30 minutes debugging...

After AI-DBUG ๐Ÿ˜Š

๐Ÿ’ก What Happened?
You're trying to use .upper() on a number (int), but .upper()
only works on text (strings).

๐Ÿ”ง How to Fix
Convert to string first: str(item).upper()

Or check the type:
if isinstance(item, str):
    item.upper()

๐Ÿ“ Example
items = [1, 2, "hello", 3]
result = [str(item).upper() for item in items]
# Output: ['1', '2', 'HELLO', '3']

Fixed in 30 seconds!

๐ŸŒŸ Show Your Support

If AI-DBUG made debugging easier for you:

  • โญ Star this repository
  • ๐Ÿฆ Tweet about it
  • ๐Ÿ“ Write a blog post
  • ๐Ÿ’ฌ Tell your friends
  • ๐Ÿค Contribute code or docs

๐Ÿ“œ Citation

If you use AI-DBUG in research or education, please cite:

@software{ai_dbug,
  title = {AI-DBUG: AI-Powered Python Debugger},
  author = {AI-DBUG Contributors},
  year = {2024},
  url = {https://github.com/jithubaiju55/ai-dbug}
}

GitHub

โญ Star us on GitHub โ€” it motivates us a lot!

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

ai_dbug-0.1.0.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

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

ai_dbug-0.1.0-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file ai_dbug-0.1.0.tar.gz.

File metadata

  • Download URL: ai_dbug-0.1.0.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for ai_dbug-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e714e00b5b70a14848acd1b63474a96e0f39d6d33e6b40096b8b30478a9286c6
MD5 aa60aae6dd6c461ab044f1c7d500c016
BLAKE2b-256 5f44a2b4ca0f63d6c4f86901fb41bf212a4320058bc575d5280c7edceee51785

See more details on using hashes here.

File details

Details for the file ai_dbug-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ai_dbug-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for ai_dbug-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b6d237cc704a56809b5658a49a3a8314096b9ac147dc7ce0ae2f7c4da82372c
MD5 38f76eff302144232656b65dc5b8e1f5
BLAKE2b-256 998a5ae19f64967ff38ffddf513c3279ae3a016b9912079b19a47a5130930b7d

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