cloudpathlib provides pathlib-style classes for interacting with files and directories in various cloud storage services such as AWS S3, Google Cloud Storage, and Azure Blob Storage. It aims to offer a familiar filesystem interface, abstracting away cloud-specific details. The library is actively maintained, with a typical release cadence that includes bug fixes and new features. The current version is 0.23.0.
pip install cloudpathlibVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a CloudPath object for S3, write text to it, read text from it, check its existence, and then delete it. Users should ensure their cloud provider authentication environment variables are correctly set for automatic authentication. Similar patterns apply to GSPath and AzureBlobPath.
Update calls to `CloudPath.copy` to use `target` as the parameter name instead of `destination`.
Upgrade your Python environment to 3.8 or newer.
If you were passing a client object as the second positional argument to `CloudPath` or `AnyPath`, ensure you pass it using the `client=` keyword argument.
Update your environment configurations to use `CLOUDPATHLIB_FILE_CACHE_MODE` instead of `CLOUPATHLIB_FILE_CACHE_MODE`.
If you require an error to be raised when attempting to unlink a non-existent file, explicitly pass `missing_ok=False` to `unlink()`.
Use `path.rmtree()` for recursive directory deletion, or ensure directories are empty before calling `path.rmdir()`.
Upgrade to `cloudpathlib` v0.18.1 or newer, and ensure your `google-cloud-storage` dependency is compatible or also updated.
Ensure your environment or system is configured with valid credentials for the respective cloud provider. For AWS S3, set `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` (if applicable). For Google Cloud Storage, set `GOOGLE_APPLICATION_CREDENTIALS` to the path of your service account key file. For Azure Blob Storage, configure environment variables like `AZURE_STORAGE_ACCOUNT_NAME` and `AZURE_STORAGE_ACCOUNT_KEY` or `AZURE_STORAGE_CONNECTION_STRING`.
Ensure your environment is configured with appropriate credentials for your cloud provider (e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION for S3; GOOGLE_APPLICATION_CREDENTIALS for GCS; AZURE_STORAGE_ACCOUNT_NAME, AZURE_STORAGE_ACCOUNT_KEY for Azure).
Install `cloudpathlib` with the appropriate extras for your cloud provider. For S3, use `pip install "cloudpathlib[s3]"`. For Google Cloud Storage, use `pip install "cloudpathlib[gs]"`. For Azure Blob Storage, use `pip install "cloudpathlib[azure]"`. To install all, use `pip install "cloudpathlib[all]"`.
Configure your cloud credentials. For AWS S3, set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables or use an `AWS_PROFILE`. For public S3 buckets, instantiate `S3Client` with `no_sign_request=True` and use that client. For Google Cloud Storage, set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. For Azure, set `AZURE_STORAGE_CONNECTION_STRING`. Alternatively, explicitly instantiate and configure a client object (e.g., `S3Client`, `GSClient`, `AzureBlobClient`) with your credentials.
Instead of directly passing a `CloudPath` object to external libraries for writing, explicitly open the `CloudPath` object for writing and pass the resulting file-like object, or write to a temporary local file first and then upload it using `cloudpathlib`'s `upload_from` method. For example, for Pandas: `with my_cloud_path.open('w') as f: df.to_csv(f)` (or `to_parquet`, etc.) or `df.to_csv('local_temp_file.csv'); my_cloud_path.upload_from('local_temp_file.csv')`.Upgrade `cloudpathlib` to a version that officially supports Python 3.13+ (e.g., v0.20.0 or later, as mentioned in a GitHub issue for 3.13 support). If a newer version of `cloudpathlib` is not yet released that supports your specific Python version, you may need to either downgrade your Python version or wait for an updated `cloudpathlib` release. Check the `cloudpathlib` GitHub repository or PyPI page for the latest compatibility information.