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 and Google Gemini. The provider is detected automatically from your API key.


✨ Key Features

  • AI Error Explanations: Get plain-English explanations of tracebacks powered by Claude or Gemini.
  • 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-...) and Google Gemini (AIza...) 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 or Google Gemini 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.0.tar.gz (11.4 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.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_fixer-1.0.0.tar.gz
  • Upload date:
  • Size: 11.4 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.0.tar.gz
Algorithm Hash digest
SHA256 cee9923ab8bda17d2be5d072dc01f5be8a5165c186cbdc60b6f26ff8bf422723
MD5 4977671aa795c3409a521ccf1710ab31
BLAKE2b-256 35e9d175bd9a2ff5ef88c700194c1fb6fdb4bd39a61380498f816ca10cde4e36

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_fixer-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29a9fe45832c95bbbe10fc061e5e5fc1d81a7561187501a8e0157ddb33df8a3c
MD5 d8ee3c24122b03a58a44fff5701d31db
BLAKE2b-256 8f2d88a3d1a56b08f20a392d6cfed77c654ce1e0a4c035ab060f634a4c966f20

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