aiopath provides an asynchronous implementation of Python's standard `pathlib` module, enabling non-blocking file system operations within `asyncio`, `trio`, and other `async`/`await` compatible frameworks. It mirrors `pathlib`'s API, making it familiar for users who need to perform I/O-bound tasks concurrently without blocking the event loop. The library is currently at version 0.7.7 and maintains an active development, addressing compatibility with newer Python versions and bug fixes.
pip install aiopathVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic asynchronous file operations using `AsyncPath`, including creating a directory, writing text to a file, reading its content, checking its properties, and cleaning up the created files and directories.
Upgrade `aiopath` to version `0.7.0` or higher to ensure compatibility with Python 3.11 and newer. For Python 3.12, version `0.7.6` or higher is recommended.
Check for updates to `aiopath` that fix `AsyncPath.walk()` to return an `AsyncGenerator`. If not fixed, consider implementing a custom async walk or using `AsyncPath.iterdir()` for recursive traversal.
Always prepend `await` to `AsyncPath` methods that perform I/O operations, such as `await my_path.exists()` or `await my_path.read_text()`.
Upgrade `aiopath` to the latest version using `pip install --upgrade aiopath`. Version `0.7.0` and newer are designed for Python 3.11+ compatibility.
Verify your `aiopath` version. If the issue persists, manually iterate using `AsyncPath.iterdir()` and `is_dir()` for a recursive async walk, or await an official fix/workaround for `AsyncPath.walk()` in the library.
Ensure all I/O-performing methods of `AsyncPath` are properly `await`ed, like `await my_path.exists()` or `await my_path.resolve()`.