windows_path
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-pathcommand? We publish both entry points—windows_pathis the official name, withwindows-pathkept 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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| windows_path-0.1.0.tar.gz | 11.2 kB | Without provenance | Details for windows_path-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| windows_path-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for windows_path-0.1.0-py3-none-any.whl |
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
|
Security for windows-path 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.