Pathy extends Python's `pathlib.Path` to provide a unified, pathlib-compatible interface for interacting with local filesystems and various cloud storage services (S3, GCS, Azure Blob Storage). It aims to make file operations cloud-agnostic and seamless. The current stable version is 0.13.0, with frequent minor and patch updates.
pip install pathyVerified import paths — ran on the pinned version, not inferred.
This example demonstrates basic file operations using Pathy for both local and cloud (S3) paths. For cloud operations, ensure the relevant `pathy` extras are installed (e.g., `pathy[s3]`) and environment variables for authentication are configured.
Review existing code for direct `pathlib.Path` inheritance assumptions or specific `pathlib` method calls. Pathy aims to maintain compatibility with `pathlib`'s public API, but internal structure has changed.
If you were chaining `.key` operations or expecting a `Pathy` object, update your code to handle a `str` return type. Convert back to `Pathy(key_string)` if a Pathy instance is needed.
Update code that inspects `stat()` results to expect `BlobStat` attributes (e.g., `st_size`, `st_mtime`) which are compatible with `os.stat_result` but now provide a unified interface. Custom attribute access might need adjustment.
Upgrade your Python environment to 3.10 or later to use recent Pathy versions.
If you have custom Pathy backends or complex extensions, review the `pathlib_abc` changes or the Pathy source for potential incompatibilities in abstract methods or internal types.
Ensure you install Pathy with the correct extras for the cloud storage you intend to use. Example: `pip install "pathy[s3]"`.
Install the pathy library using pip: `pip install pathy`
Check the pathy documentation for the correct method name and its availability for the specific cloud storage backend you are using. If the method is from `pathlib.Path`, ensure it's supported by `pathy.Pathy` or adjust your logic accordingly.
Verify that your cloud provider credentials (e.g., service account key file for GCS, AWS access key ID and secret access key for S3, Azure storage account name and key) are correctly configured and have the necessary permissions for the requested operation. Check environment variables or configuration files Pathy uses for credentials.
Double-check the cloud path for correctness, including bucket name, prefixes, and object name. Ensure the file or directory actually exists in your cloud storage. You can use methods like `.exists()` on the `Pathy` object to programmatically check for existence before attempting operations.