pathlib3x
raw JSON → 2.0.3 verified Mon Apr 27 auth: no python maintenance
A backport of Python 3.10's pathlib module to Python 3.6-3.9 (now 3.8+) with a few extensions. It aims to provide a pure-Python drop-in replacement for pathlib.Path with additional features like globbing and pattern matching from later versions. Current version: 2.0.3, release cadence is low.
pip install pathlib3x Common errors
error ModuleNotFoundError: No module named 'pathlib3x' ↓
cause Package not installed or environment mismatch.
fix
Run
pip install pathlib3x in the correct environment. error AttributeError: module 'pathlib' has no attribute 'Path' ↓
cause Mistakenly imported stdlib pathlib instead of pathlib3x.
fix
Use
from pathlib3x import Path instead of from pathlib import Path. Warnings
deprecated Python 3.10+ users: pathlib3x is unnecessary; use the standard library. ↓
fix Remove pathlib3x dependency and use `from pathlib import Path`.
gotcha pathlib3x is pure Python, not implemented in C like the stdlib pathlib. Performance may be notably slower for large directory trees. ↓
fix If performance is critical, consider using `pathlib` from stdlib or `scandir`.
breaking pathlib3x 2.0.0 dropped Python 3.6 and 3.7 support. Only 3.8+ is supported. ↓
fix Update Python to 3.8+ if pinned to pathlib3x>=2.0.0.
Imports
- Path wrong
from pathlib import Pathcorrectfrom pathlib3x import Path
Quickstart
from pathlib3x import Path
p = Path('/tmp')
print(p.exists())
# Using extended features (e.g., glob with pattern matching)
for f in p.glob('**/*.txt'):
print(f)