aiofiles
aiofiles is a Python library that provides asynchronous file operations for asyncio applications, enabling non-blocking file I/O. The current version is 25.1.0, released on October 9, 2025. The library follows a regular release cadence, with updates approximately every few months.
Warnings
- breaking Python 3.8 support dropped in aiofiles 25.1.0
- gotcha Ensure to use 'async with' when working with aiofiles to avoid 'AttributeError: __enter__' errors
Install
-
pip install aiofiles
Imports
- open
from aiofiles import open
Quickstart
import aiofiles
import asyncio
async def read_file():
async with aiofiles.open('example.txt', mode='r') as f:
contents = await f.read()
print(contents)
asyncio.run(read_file())