CLI tool that diagnoses and auto-fixes Python/ML environment errors using a local LLM.
Project description
envfix ๐ ๏ธ
envfixwraps any failing shell command, asks a local AI model what went wrong, and proposes a one-click fix โ fully offline, no API key, no cloud.
without envfix with envfix
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
$ python train.py $ envfix run python train.py
ModuleNotFoundError: โ Command Failed
No module named 'torch' โ ModuleNotFoundError: No module named 'torch'
โ Google the error ๐ค Asking Ollama (llama3.1:8b)โฆ
โ Stack Overflow rabbit hole
โ Try three different pip commands โญโโโโโโโโโโโ envfix Suggestion โโโโโโโโโโโโโฎ
โ Wrong CUDA version โ DIAGNOSIS โ
โ Try again โ PyTorch is not installed in this env. โ
โ โ
~20 minutes later: โ FIX โ
$ python -m pip install torch โ python -m pip install torch โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Run this fix? [y/n] (n): y
โ Success! The fix resolved the issue.
(total time: ~30 seconds)
โ ๏ธ Early / experimental. Works best for common Python, Node.js, and package-manager errors. See Known limitations.
Prerequisites
| Requirement | Version | Why |
|---|---|---|
| Python | โฅ 3.10 | f-strings, match syntax |
| Ollama | latest | (Optional) runs the local AI model |
| API Keys | (Optional) GROQ_API_KEY or GEMINI_API_KEY for cloud models |
|
| RAM | โฅ 8 GB | for local llama3.1:8b โ or โฅ 4 GB for qwen2.5:3b |
Install
Step 1 โ Choose your AI provider
envfix supports local and cloud models.
Option A (Default): Local Ollama Download from ollama.com/download (Windows, macOS, Linux).
On Linux you can also run:
curl -fsSL https://ollama.com/install.sh | sh
Step 2 โ Pull a model
# Recommended (needs ~8 GB RAM free)
ollama pull llama3.1:8b
# Lighter alternatives if you have โค 4 GB free RAM
ollama pull qwen2.5:3b
ollama pull llama3.2:3b
Option B: Groq API (Cloud)
- Get a free API key from console.groq.com.
- Set it in your terminal:
# Windows PowerShell $env:GROQ_API_KEY="your-key-here" # Linux/macOS export GROQ_API_KEY="your-key-here"
Option C: Gemini API (Cloud)
- Get a free API key from Google AI Studio.
- Set it in your terminal:
# Windows PowerShell $env:GEMINI_API_KEY="your-key-here" # Linux/macOS export GEMINI_API_KEY="your-key-here"
Step 3 โ Start Ollama
ollama serve
Windows tip: The Ollama installer adds a system-tray icon that starts the service automatically on login โ you may be able to skip this step. (Skip this step if you are using Groq or Gemini).
Step 4 โ Install envfix
git clone https://github.com/LOVEKUSH-rgb/deepproblemsolver.git
cd deepproblemsolver
pip install -e .
Why
-e? Editable mode means changes to the source code take effect immediately without reinstalling. For a "permanent" install just usepip install .instead.
Verify the install:
envfix --help
Usage
envfix run <your failing command>
Common examples
# Missing Python module
envfix run python -m non_existent_module
# Broken requirements file
envfix run python -m pip install -r requirements.txt
# Node / npm error
envfix run npm run build --category node
# CUDA / GPU error
envfix run python train.py --gpu 0
# Use a lighter model on a low-RAM machine
envfix run python train.py --model qwen2.5:3b
# Use a cloud provider instead of local Ollama
envfix run npm install --provider groq
envfix run npm install --provider gemini
# Check your fix history
envfix history
envfix history --last 5
What you'll see
โถ Running: python -m pip install -r requirements.txt
โญโโโโโโโโโโโโ โ Command Failed โโโโโโโโโโโโโฎ
โ ERROR: Could not find a version that โ
โ satisfies the requirement bogus-pkg โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐ค Asking Ollama (llama3.1:8b) for a diagnosisโฆ
โญโโโโโโโโโโ envfix Suggestion โโโโโโโโโโโโโโฎ
โ DIAGNOSIS โ
โ The package 'bogus-pkg' does not exist โ
โ on PyPI. โ
โ โ
โ FIX โ
โ python -m pip install <correct-name> โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐ What this will do: Installs a package from PyPI
Run this fix? [y/n] (n): y
If the same (or very similar) error has appeared before, envfix skips the
model call entirely and shows the cached suggestion instead:
โก Found a previously verified fix (97% match) โ skipping model call.
If the suggested fix contains a destructive command (rm -rf, sudo,
delete, etc.), envfix shows an explicit warning and requires you to type
yes in full:
โ ๏ธ DANGEROUS COMMAND DETECTED
This command may delete files, change permissions, or execute remote code.
Type 'yes' to run this fix (no):
Command reference
| Command | What it does |
|---|---|
envfix run <cmd> |
Run a command; diagnose + suggest fix on failure |
envfix run <cmd> --provider <name> |
Select AI provider (ollama [default], groq, gemini) |
envfix run <cmd> --model <tag> |
Use a specific model tag/name for the chosen provider |
envfix run <cmd> --category <eco> |
Hint the ecosystem (python, node, docker โฆ) |
envfix history |
Show the last 20 attempts |
envfix history --last N |
Show last N attempts |
How it works
envfix run <cmd>
โ
โผ
subprocess: run the command, capture stderr
โ
succeeded? โโYesโโโบ โ Nothing to fix
โ
No
โผ
Check per-user log (envfix_log_<username>.json) for similar past error
โ
Cache hit โโYesโโโบ Show cached fix (skip Ollama)
โ
No
โผ
Build structured prompt โ POST to local Ollama service
โ
โผ
Parse DIAGNOSIS + FIX from model response
โ
โผ
Dry-run description for non-obvious commands
Destructive guard for dangerous commands (requires "yes" in full)
โ
โผ
User approves โ apply fix โ re-run original command
โ
โผ
Log result to envfix_log_<username>.json
Per-user history
Every attempt is logged to envfix_log_<username>.json in the directory where
you run envfix. Each user on the same machine gets their own separate file โ
no shared state, no accounts.
The file is excluded from git by .gitignore so your personal history never
gets committed.
Sample entry:
{
"timestamp": "2026-07-26T08:00:00Z",
"original_command": "python train.py",
"error_text": "ModuleNotFoundError: No module named 'torch'",
"diagnosis": "PyTorch is not installed in this environment.",
"fix_command": "python -m pip install torch",
"user_approved": true,
"fix_worked": true,
"source": "ollama",
"category": "python",
"context_included": false,
"provider": "ollama"
}
Known limitations
- Model quality varies.
envfixis only as good as the local model you pull. Smaller models (qwen2.5:3b,llama3.2:3b) sometimes produce vague or wrong diagnoses for complex errors.llama3.1:8bis the recommended minimum. - Works best for common errors. Highly project-specific errors (e.g. a bug in your custom C extension) will likely produce generic suggestions.
- Windows path assumptions. The tool normalises
pip installโpython -m pip installbecausepipis often not on the Windows PATH. On macOS/Linux both forms work but the normalisation is harmless. - Single fix per failure.
envfixproposes one fix at a time. If the first fix doesn't work, runenvfix run <cmd>again โ the model may suggest something different. - Needs Ollama running. If
ollama serveis not active,envfixexits with a clear error message rather than a cryptic timeout. - Still early. Prompt engineering and cache fuzzy-matching were tuned for Python/ML and Node errors. Other ecosystems (Rust, Docker, CMake โฆ) will work but with less accuracy.
Running the tests
# No Ollama needed โ all tests are offline
python -m pytest tests/ -v
67 tests across three files covering the AI parser, subprocess runner, JSON logger, two-tier cache, dry-run preview, safety guardrails, and per-category matching.
Troubleshooting
| Symptom | Fix |
|---|---|
Error reaching Ollama: Connection refused |
Run ollama serve in a separate terminal |
model "llama3.1:8b" not found |
Run ollama pull llama3.1:8b |
envfix: command not found |
Run pip install -e . from the repo root |
| Fix runs but original still fails | The model diagnosis was wrong โ run again or fix manually |
| Model returns garbled output | Try --model qwen2.5:3b |
| Always shows cached (wrong) fix | Cache threshold is 0.85; if the fix is wrong, say n and re-run โ Ollama will be called fresh |
Contributing
See CONTRIBUTING.md for the module map, ground rules, and how to submit a fix.
License
This project is licensed under the Business Source License 1.1 (BSL 1.1). It requires a commercial license for enterprise/managed service use. See the LICENSE file for complete details.
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 envfix-0.5.0.tar.gz.
File metadata
- Download URL: envfix-0.5.0.tar.gz
- Upload date:
- Size: 46.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3a062d05bbbbae21fbb689f9529c9a3ff8cd357e03b051d1fffb53a81a7b50e
|
|
| MD5 |
d0e22e543469b1c26a90e7b679641c94
|
|
| BLAKE2b-256 |
46338395c55e1b1abf67f909c90ee6cdd06d0c6506aea9d78c50807ea495d916
|
File details
Details for the file envfix-0.5.0-py3-none-any.whl.
File metadata
- Download URL: envfix-0.5.0-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba4184d4e5058b407af8d541f6294509c61a08497f1985008e6b18b11f471bbb
|
|
| MD5 |
e3e56274e0aa277aa07bf5569bd44ce4
|
|
| BLAKE2b-256 |
f58bd394df227c4b7833f4e3cf6d37a6c36b1b633bdcf1d09cb8cbd14f8e316e
|