How to Install aiofiles in Python

v25.1.0 Async & Networking Python >=3.9 Apache-2.0

File support for asyncio.

Install pip install aiofiles

What is aiofiles?

File support for asyncio.

aiofiles is an Apache2 licensed library, written in Python, for handling local disk files in asyncio applications.

Ordinary local file IO is blocking, and cannot easily and portably be made asynchronous. This means doing file IO may interfere with asyncio applications, which shouldn't block the executing thread. aiofiles helps with this by introducing asynchronous versions of files that support delegating operations to a separate thread pool.

Asynchronous iteration is also supported.

Quick Start

Minimal example to get started with aiofiles:

import aiofiles
import asyncio

async def main():
    async with aiofiles.open("data.txt", "w") as f:
        await f.write("Hello, async world!")
    async with aiofiles.open("data.txt") as f:
        print(await f.read())

asyncio.run(main())

Installation

pip (standard)

pip install aiofiles

Virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install aiofiles

pip3

pip3 install aiofiles

conda

conda install -c conda-forge aiofiles

Poetry

poetry add aiofiles

Verify the Installation

After installing, confirm the package is available:

python -c "import aiofiles; print(aiofiles.__version__)"

If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.

Installation Errors

Common errors when installing aiofiles with pip.

ModuleNotFoundError: No module named 'aiofiles'

Cause: The package is not installed in the current Python environment.

Fix: Run pip install aiofiles. If using a virtual environment, ensure it is activated first.

ModuleNotFoundError: No module named 'aiofiles' (installed but still failing)

Cause: pip installed the package into a different Python than the one running your script.

Fix: Use python -m pip install aiofiles to install into the interpreter you are running.

ImportError: cannot import name 'X' from 'aiofiles'

Cause: The function or class does not exist in the installed version.

Fix: Check the version with pip show aiofiles and upgrade with pip install --upgrade aiofiles.

pip: command not found

Cause: pip is not in PATH or Python was not added to PATH during installation.

Fix: Try python -m pip install aiofiles. On macOS/Linux try pip3.

PermissionError: [Errno 13] Permission denied

Cause: No write access to the system Python package directory.

Fix: Use a virtual environment, or add --user: pip install --user aiofiles

SSL: CERTIFICATE_VERIFY_FAILED

Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.

Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org aiofiles

RuntimeError: This event loop is already running

Cause: Calling <code>asyncio.run()</code> inside Jupyter or another already-running event loop.

Fix: In Jupyter, use await directly. Or install nest_asyncio and call nest_asyncio.apply().

Recent Releases

VersionReleased
25.1.0 latest 2025-10-09
24.1.0 2024-06-24
23.2.0 2023-08-09
23.2.1 2023-08-09
23.1.0 2023-02-09

Full release history on PyPI →

Manage aiofiles

Upgrade to latest version

pip install --upgrade aiofiles

Install a specific version

pip install aiofiles==25.1.0

Uninstall

pip uninstall aiofiles

Check what is installed

pip show aiofiles

Last updated: 2026-04-11 • Data from PyPI