Skip to main content

Python virtual environment doctor — diagnose and fix broken venvs, pip, poetry locks

Project description

xnv — Python Virtual Environment Doctor

Diagnose and fix broken Python virtual environments, stale poetry locks, and pip issues.

Install

pip install -e .

Usage

# Diagnose environment health
xnv doctor

# Diagnose a specific project
xnv doctor /path/to/project

# Auto-fix all issues (recreate broken venv + install deps)
xnv fix

# Force recreate venv even if healthy
xnv fix --force

# Fix without installing dependencies
xnv fix --no-install

# Fix with dev dependencies
xnv fix --dev

# Remove venv completely
xnv nuke

# Create fresh venv
xnv create

# Regenerate poetry.lock
xnv lock

What it detects

Code Severity Description
VENV_BROKEN_PYTHON error Python symlink points to missing target
VENV_NO_PYTHON error Python binary missing from venv
VENV_PYTHON_FAIL error Python binary not executable
VENV_BROKEN_PIP error pip symlink broken
VENV_NO_PIP error pip binary missing
VENV_PIP_FAIL error pip not functional
VENV_PIP_SHIM_BROKEN error pip shim broken but python -m pip works
VENV_STALE_HOME error pyvenv.cfg points to missing Python install
POETRY_LOCK_STALE error poetry.lock out of sync with pyproject.toml
NO_VENV warn No virtual environment found
VENV_MISMATCH warn Active VIRTUAL_ENV differs from project venv
NO_PYPROJECT warn No pyproject.toml found
CONDA_ACTIVE info Conda environment detected

What xnv fix does

  1. Runs full diagnosis
  2. If poetry.lock is stale → poetry lock
  3. If venv is broken → removes and recreates with system Python
  4. Installs dependencies via Poetry (preferred) or pip
  5. Verifies the fix

Python API

from xnv.diagnose import diagnose
from xnv.fix import fix

# Diagnose
diag = diagnose("/path/to/project")
print(diag.healthy)  # True/False
for issue in diag.issues:
    print(f"[{issue.severity}] {issue.code}: {issue.message}")

# Fix
ok = fix("/path/to/project", force_recreate=False, install=True, dev=False)

License

MIT

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

xnv-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

xnv-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file xnv-0.1.0.tar.gz.

File metadata

  • Download URL: xnv-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Linux/6.17.0-14-generic

File hashes

Hashes for xnv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b0ecd3fb550f55b61d522f8d929d998d92a699a42e425641a84e64fb5473d66
MD5 6d36a1ddff7ad21b25a6d714ec866cfc
BLAKE2b-256 851ef13f25c1d88158285d603593143be8a5c3206cb49b03cd730a665a42ca76

See more details on using hashes here.

File details

Details for the file xnv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: xnv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Linux/6.17.0-14-generic

File hashes

Hashes for xnv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abe01671349905e6c31df99d32f6db0d25f5806bee6f462837a93fca0f3531f2
MD5 bccc528cb63dd86dad48ee4d5dba6ec1
BLAKE2b-256 9bc665965d0c703550830105af6be89d3bfcb7a0445b42024d81d59fe67594b5

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