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
- Fork the repository
- Edit
ai_dbug/knowledge_base.py - Add your error with explanation, fix, and example
- Add tests in
tests/test_ai_dbug.py - 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
- ๐ Bug Reports: GitHub Issues
- ๐ง Email: ithubaiju124@gmail.com
- ๐ Star us: If AI-DBUG helped you, give us a star!
๐บ๏ธ 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}
}
โญ Star us on GitHub โ it motivates us a lot!
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e714e00b5b70a14848acd1b63474a96e0f39d6d33e6b40096b8b30478a9286c6
|
|
| MD5 |
aa60aae6dd6c461ab044f1c7d500c016
|
|
| BLAKE2b-256 |
5f44a2b4ca0f63d6c4f86901fb41bf212a4320058bc575d5280c7edceee51785
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b6d237cc704a56809b5658a49a3a8314096b9ac147dc7ce0ae2f7c4da82372c
|
|
| MD5 |
38f76eff302144232656b65dc5b8e1f5
|
|
| BLAKE2b-256 |
998a5ae19f64967ff38ffddf513c3279ae3a016b9912079b19a47a5130930b7d
|