Skip to main content

Run Python scripts with AI-powered error explanations

Project description

pyfixer

License PyPI Python

A drop-in replacement for python that runs your scripts normally — but when an error occurs, uses AI to explain what went wrong and suggest a fix, right in your terminal.

Supports Anthropic Claude, Google Gemini, and OpenAI. The provider is detected automatically from your API key.


Key Features

  • AI Error Explanations: Get plain-English explanations of tracebacks powered by Claude, Gemini, or OpenAI.
  • VS Code Diff View: See suggested fixes as a side-by-side diff before applying anything.
  • One-Click Apply: Accept or discard fixes interactively — originals are backed up automatically.
  • Multi-Provider: Works with Anthropic (sk-ant-...), Google Gemini (AIza...), and OpenAI (sk-...) keys.
  • No lock-in: Use --no-explain to skip AI entirely and behave like plain python.

Installation

pip install py-fixer

Quick Start

1. Store your API key

pyfixer login

Paste your API key when prompted — you'll also choose a model. Credentials are saved to ~/.config/pyfixer/config.json (mode 600).

2. Run a script

pyfixer run script.py

When an error occurs, pyfixer:

  1. Prints the full traceback
  2. Explains the error in plain English
  3. Opens a VS Code diff showing the suggested fix
  4. Asks whether to apply it — original is backed up to .pyfixer-backup/
pyfixer run script.py arg1 arg2     # forward args to your script
pyfixer run script.py --no-explain  # traceback only, no AI

Commands

Command Description
pyfixer login Save your API key and choose a model
pyfixer logout Remove your stored API key and model
pyfixer run <script> Run a script with AI error explanations
pyfixer set-model Switch models without re-entering your key
pyfixer install-extension Install the VS Code extension for inline fixes

Requirements

  • Python 3.10+
  • An Anthropic, Google Gemini, or OpenAI API key
  • VS Code (optional, for diff view)

Contributing

Bug reports and pull requests are welcome! Please open an issue at github.com/ayushisahu222/py-fixer/issues.


License

This project is licensed under the MIT License.

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

py_fixer-1.0.2.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

py_fixer-1.0.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file py_fixer-1.0.2.tar.gz.

File metadata

  • Download URL: py_fixer-1.0.2.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for py_fixer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f7ec2510a4c16892fecc743a87f0eeb07ffc9ed4cf9df03dd2d13277afe3c7f6
MD5 3f0fbd958d2e798983c6d5c638ef03cb
BLAKE2b-256 d231b7971f015be169e6422274f21d87c4e0cb7fd6cb61a19dc517095e9a177e

See more details on using hashes here.

File details

Details for the file py_fixer-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: py_fixer-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for py_fixer-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d37a1de2985b20d83dae4f57fbe3155bb8444ac8c1a149ba0052ff72a284c027
MD5 9ee029da236e4f5755c193f830de5261
BLAKE2b-256 91f3f22a488739ed994eb69496a95dbba254c05a39d7741eec808a68e0b4911e

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