Skip to main content

Manage the Windows user PATH environment variable from Python or the command line.

Project description

windows_path

Twitter Follow Downloads PyPI - Python Version PyPI version

Manage the Windows user PATH environment variable from Python or the command line.

Features

  • List, search, add, remove, and reorder entries in the user PATH
  • Clean out invalid or duplicate entries safely
  • Backup and restore PATH values to JSON files
  • Export PATH contents to plain text, CSV, or Markdown
  • Library API and ready-to-use CLI (windows_path) with detailed logging

Note This utility targets Windows (sys.platform == "win32"). The commands exit early on other platforms.

Installation

Install from PyPI:

pip install windows_path

Or with uv:

uv add windows_path

To build and install from this repository:

pip install --upgrade build
python -m build
pip install dist\windows_path-*.whl

Need a deep-dive? See docs/windows-path-guide.md for the full walkthrough including automation tips and legacy command references.

Prefer the old windows-path command? We publish both entry points—windows_path is the official name, with windows-path kept as an alias for compatibility.

Command Line Usage

All CLI features are exposed through the windows_path command (or by running python -m windows_path). The legacy windows-path alias remains available.

windows_path list
windows_path add "C:\Tools"
windows_path add --position start "C:\CustomBin"
windows_path remove "C:\OldTools"
windows_path clean --force
windows_path deduplicate
windows_path search python
windows_path backup
windows_path restore path_backup_20250103.json
windows_path export csv > paths.csv

Use windows_path --help for the full command reference (or windows-path --help if you prefer the alias).

Exit Codes

Code Meaning
0 Success
1 General error
2 Permission denied
3 Concurrent update conflict
4 Validation error

Python API

from windows_path import PathManager

manager = PathManager(verbose=True)
manager.list_paths()
manager.add_path(r"C:\\Tools")
manager.deduplicate_paths()
manager.backup_path()

All operations raise windows_path.PathManagerError (with an exit_code attribute) on failure. Path updates detect concurrent modifications and retry automatically.

Development

  • Python 3.6+
  • Windows (required for registry access)

Useful commands:

# Install in editable mode
pip install -e .

# Run a smoke check on syntax
python -m compileall windows_path

Feel free to open issues or pull requests to report bugs or suggest enhancements.

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

windows_path-0.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

windows_path-0.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for windows_path-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e6a8cbc2b5b947e3fadfdceacf83194b4c98b6306e2bdd455a782fc779643cfd
MD5 2ccae047f32616db8d04e992c2dd09be
BLAKE2b-256 c3ca29f74a133564b7e351c7b75defe896399fa0e85837f01a922418033a49fc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for windows_path-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a6593bb4d7b25d5001b1909e40824c5b0f49915a95921de97f5eaaf867df297
MD5 3ae44798264324b39c03947a9d923156
BLAKE2b-256 43b448eaa0b0a72e195dc40d61b8d139c90f73726552140ecb4d7d46962a284e

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