Scan and repair conda/mamba/micromamba environments with mixed conda/pip installs.
Project description
🩺 EnvRepair 
Fixing broken Python environments – safely, transparently, reproducibly
EnvRepair is a practical repair tool for the messy reality of Python environments:
Conda / Mamba / Micromamba mixed with pip, plus plain venv / virtualenv.
Instead of starting over (again), EnvRepair helps you understand what’s broken, why it’s broken, and fix it safely – with snapshots and rollback support, so you’re never locked in.
🤕 Why EnvRepair Exists
If you’ve ever seen things like:
- duplicate
.dist-infofolders - mysterious
.pydconflicts on Windows conda-metaJSON files that suddenly break tools like PyInstaller- environments that are “inconsistent” but still half-working
- pip + conda silently stepping on each other’s toes
…then EnvRepair is for you.
It doesn’t try to replace conda or pip.
It steps in after things already went wrong.
✨ What EnvRepair Can Do
🔍 Diagnose
- Detect duplicates and leftovers (
.dist-info, stale artifacts, some Windows.pydduplicates). - Find corrupted or incomplete
conda-metaentries. - Detect pip/conda case-sensitivity conflicts.
🛠️ Repair (carefully!)
- Repair mixed conda + pip installs using the right tool.
- Reinstall broken packages with source awareness.
- “Adopt” pip packages into conda where possible (
--adopt-pip). - Handle plain venv / virtualenv setups (pip-only mode).
🛟 Safety First
- Automatic rescue snapshots before any destructive action.
- Graceful recovery after
Ctrl+C. - Clear prompts instead of silent force-fixes.
🧰 Requirements
- Windows, Linux, or macOS.
mambain PATH for conda-style envs (preferred).conda/micromambaare supported when available.condais optional: mamba-only installs (e.g. Mambaforge/Miniforge variants) are supported.- Python available in the target environment.
🚀 Quick Start
All examples below use Windows
cmd.exesyntax (.batblocks).
Adjust paths/shells as needed for Linux/macOS.
Basic scan (auto-discovers conda envs):
python env_repair.py
Install as a CLI (editable):
pip install -e .
env-repair --help
Install from local checkout (non-editable):
pip install .
🔁 Common Workflows
Fix base:
python env_repair.py --env base --fix
Fix a plain venv (pip-only):
python env_repair.py --env .venv --fix
Same via installed CLI:
env-repair --env base --fix
Adopt pip packages into conda (where possible):
python env_repair.py --env base --fix --adopt-pip
Verify imports (and fix what can be fixed):
python env_repair.py verify-imports --env base --full --fix
⏪ Rollback & Rebuild
Rollback to previous conda revision:
env-repair rollback --env base --to prev
Rollback without prompt:
env-repair rollback --env base --to prev -y
Rebuild into a new env (name):
env-repair rebuild --env base --to base-rebuilt --verify
Rebuild into a new env (path):
env-repair rebuild --env base --to C:\temp\base-rebuilt --verify
🧪 Advanced Diagnostics
Diagnose a ClobberError from a logfile:
env-repair diagnose-clobber --env base --logfile clobber.txt
Diagnose / fix “inconsistent” env:
env-repair diagnose-inconsistent --env base
env-repair fix-inconsistent --env base --level safe
Cache check / fix:
env-repair cache-check
env-repair cache-fix --level safe
SSL diagnosis:
env-repair diagnose-ssl --base
env-repair diagnose-ssl --env base
Create a conda-style snapshot (YAML):
python env_repair.py --env base --snapshot snapshots\base.yaml
Debug output:
python env_repair.py --env base --fix --adopt-pip --debug
🛟 Safety Net (Ctrl+C / Rescue)
- When you run with
--fix, EnvRepair creates a rescue snapshot under:.env_repair\snapshots\... - If you abort during a pip/mamba/conda step, EnvRepair will prompt:
rrestore from snapshotccontinue (skip)aabort (default)
- A
.env_repair\state.jsonfile records progress so you can inspect what happened and re-run later.
🔎 Import Verification (verify-imports)
EnvRepair can scan installed distributions and run python -c "import <name>" for their top-level modules.
Full scan + auto-fix (recommended when an env is “mostly working but randomly broken”):
python env_repair.py verify-imports --env base --full --fix --debug
Both --env placements are supported:
env-repair --env base verify-imports --full --fix
env-repair verify-imports --env base --full --fix
Notes:
- Repairs use batched conda/mamba operations (no slow one-by-one reinstalls).
- If the solver fails for a specific package, EnvRepair retries the batch without the offending spec and remembers it in:
.env_repair\verify_imports_blacklist.json
- Platform-only modules are skipped (e.g.
shon Windows,ptyprocessmissingfcntlon Windows).
🧑💻 Development
Run tests:
python -m unittest discover -s tests -p "test_*.py"
JSON output:
python env_repair.py --env base --json
Release helper (patch bump in pyproject.toml):
python release.py
python release.py --sync
Sync conda recipe metadata from project version:
python tools\sync_versions.py
python tools\sync_versions.py --pypi-sdist --staged-recipes staged-recipes
📝 Notes
--adopt-pipinstalls only mapped PyPI packages.--adopt-pipis conda-only; for plain venvs it is ignored.- After successful adoption, env-repair uninstalls the pip version by default; use
--keep-pipto skip. - For alias-like mappings (e.g. pip
msgpack→ condamsgpack-python), pip is only removed if both versions match. - Channels are loaded from
.condarcfirst, thendefaultsandanacondaunless disabled. --debugprints the exact external command lines as[cmd] ...(mamba/conda/pip), and streams live output to keep long operations transparent.
📁 Files
env_repair.py– CLI shim (kept for convenience).env_repair/– actual implementation.docs/– design notes, feature specs, and roadmaps.
📦 Releases
PyPI releases are automated via GitHub Actions (Trusted Publishing) on tags:
vX.Y.Z→.github/workflows/release-pypi.yml
conda-forge publishing is done via a feedstock (standard conda-forge process). For details see:
docs/releasing.md
Local conda recipe (for testing) lives in:
conda.recipe/
❤️ Philosophy
EnvRepair is opinionated, but cautious.
It prefers understanding and repair over brute-force reinstallation.
If you’ve ever said “I’ll just recreate the environment…”
EnvRepair is here to save you that hour.
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
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 env_repair-0.2.4.tar.gz.
File metadata
- Download URL: env_repair-0.2.4.tar.gz
- Upload date:
- Size: 57.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49efd576ebecd898da10444d8b5b7f6820f34294f091b3db95efb0de593c8d8b
|
|
| MD5 |
ec18d0e7558b4bbfbef3f01917fdf5d4
|
|
| BLAKE2b-256 |
37c91a775c9565edb5803aeb5915a572ff078977e83cf4fb9fd505b129d7512d
|
Provenance
The following attestation bundles were made for env_repair-0.2.4.tar.gz:
Publisher:
release-pypi.yml on noragen/env-repair
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
env_repair-0.2.4.tar.gz -
Subject digest:
49efd576ebecd898da10444d8b5b7f6820f34294f091b3db95efb0de593c8d8b - Sigstore transparency entry: 933768558
- Sigstore integration time:
-
Permalink:
noragen/env-repair@ca47535ca441ef8f9a7a9711e6439ff8046a59a2 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/noragen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@ca47535ca441ef8f9a7a9711e6439ff8046a59a2 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file env_repair-0.2.4-py3-none-any.whl.
File metadata
- Download URL: env_repair-0.2.4-py3-none-any.whl
- Upload date:
- Size: 52.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d9a44e77f7b80980bb97a248f4ce3dfdbcb2864034fa6b6d529fbc5f0b6846d
|
|
| MD5 |
c912d035bb44f3423f97e3241c1b21d4
|
|
| BLAKE2b-256 |
69528fe8e57223857d7e7946b126ca34b92316a25223a560ee27f53ba407e97a
|
Provenance
The following attestation bundles were made for env_repair-0.2.4-py3-none-any.whl:
Publisher:
release-pypi.yml on noragen/env-repair
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
env_repair-0.2.4-py3-none-any.whl -
Subject digest:
6d9a44e77f7b80980bb97a248f4ce3dfdbcb2864034fa6b6d529fbc5f0b6846d - Sigstore transparency entry: 933768602
- Sigstore integration time:
-
Permalink:
noragen/env-repair@ca47535ca441ef8f9a7a9711e6439ff8046a59a2 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/noragen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@ca47535ca441ef8f9a7a9711e6439ff8046a59a2 -
Trigger Event:
workflow_dispatch
-
Statement type: