pathlib2
Object-oriented filesystem paths
What it is and what it does
pathlib2 is a backport of Python's standard pathlib module, designed to bring modern path-handling APIs to older Python versions that predate pathlib's inclusion in the standard library. It provides an object-oriented interface for working with filesystem paths across platforms, replacing string-based path manipulation with a cleaner, more intuitive API. The package depends on six, scandir, and typing to maintain compatibility across Python 2.7 and early Python 3 releases.
The backport tracks the standard library's pathlib implementation, so features added to the standard module are eventually available through pathlib2 on older Python versions. However, it carries a known limitation: on Windows with Python 2.7, non-ASCII filename characters may be silently corrupted due to the platform's filesystem encoder having poor Unicode support. Development now occurs primarily in the Python standard library itself, making this package a maintenance-light compatibility shim rather than an actively developed project.
Use it for:
- Migrate legacy Python 2.7 codebases to use modern pathlib syntax before upgrading to Python 3.
- Maintain a single codebase across Python 2.7 and early Python 3.x versions using consistent path APIs.
- Use pathlib's object-oriented path interface in projects that must support Python 3.5 or 3.6.
- Backport pathlib features to environments where the standard library version is unavailable or outdated.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Backport of Python's standard pathlib module for older Python versions, providing object-oriented filesystem path manipulation.
No, unless you are maintaining legacy Python 2.7 or very early Python 3 code. Modern Python versions include pathlib in the standard library; use that instead. The package is stable and permissively licensed, but dormant maintenance and the availability of built-in pathlib make it unnecessary for new projects.
Install
pathlib2 on PyPI
pip
pip install pathlib2uv
uv add pathlib2poetry
poetry add pathlib2Installing pathlib2
Before you install
Low install friction with a pure-Python wheel. Dormant maintenance status—last release was 2022-02-10 and last commit 2023-09-29—but the package is stable and tracks the standard library, so updates are infrequent by design.
License in practice
MIT license (permissive) allows use in commercial and open-source projects with minimal restrictions.
Quickstart
pip install pathlib2
from pathlib2 import Path
p = Path('/home/user/file.txt')
print(p.exists())
Intended for Python 2.7 and early Python 3.x; modern Python versions include pathlib in the standard library and should use that instead.
Verify before relying
- Whether the package is still actively maintained or if it is effectively superseded by the standard library pathlib.
- Current compatibility with Python versions beyond 3.9 and whether the package is tested against modern releases.
- Whether the Windows Python 2.7 unicode filename issue (issue #56) remains unfixed and affects current users.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — six, scandir, typing |
| Maintenance | dormant — 1,646 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,426,297/month — #2,304 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pathlib2-2.3.7.post1-py2.py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
pathlibProvides object-oriented filesystem path…
permissive · top 5,000 on PyPI
pathlib3xBackport of Python 3.11 pathlib to Python 3.8+…
permissive · top 15,000 on PyPI
pyProvides cross-platform path objects, INI file…
permissive · top 1,000 on PyPI
path.pyProvides Path objects that wrap filesystem…
permissive · top 15,000 on PyPI
pathlib-abcProvides abstract base classes for implementing…
permissive · top 1,000 on PyPI
traceback2Provides a backport of Python's traceback…
permissive · top 5,000 on PyPI
urlpathURLPath extends pathlib.PurePath to treat URLs…
permissive · top 15,000 on PyPI
pathProvides Path objects that wrap filesystem…
permissive · top 5,000 on PyPI
configparser2Backport of Python 3's configparser module to…
permissive · top 15,000 on PyPI
artifactoryProvides a pathlib-like Python interface for…
permissive · top 15,000 on PyPI