Skip to main content

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.

Metadata

Release files for windows-path 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for windows-path 0.1.0
File Size Uploaded
windows_path-0.1.0.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for windows-path 0.1.0
File Interpreter ABI Platform
windows_path-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / windows_path-0.1.0.tar.gz

Download URL windows_path-0.1.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e6a8cbc2b5b947e3fadfdceacf83194b4c98b6306e2bdd455a782fc779643cfd
BLAKE2b-256 checksum
How to use checksums
c3ca29f74a133564b7e351c7b75defe896399fa0e85837f01a922418033a49fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / windows_path-0.1.0-py3-none-any.whl

Download URL windows_path-0.1.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a6593bb4d7b25d5001b1909e40824c5b0f49915a95921de97f5eaaf867df297
BLAKE2b-256 checksum
How to use checksums
43b448eaa0b0a72e195dc40d61b8d139c90f73726552140ecb4d7d46962a284e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page