How to Install pytest-asyncio in Python

v1.3.0 Testing & QA Python >=3.10

Pytest support for asyncio

Install pip install pytest-asyncio

What is pytest-asyncio?

Pytest support for asyncio

is a plugin. It facilitates testing of code that uses the library.

Specifically, pytest-asyncio provides support for coroutines as test functions. This allows users to await code inside their tests. For example, the following code is executed as a test item by pytest:

@pytest.mark.asyncio async def testsomeasynciocode(): res = await library.dosomething() assert b"expected result" == res

Quick Start

Minimal example to get started with pytest-asyncio:

import pytest_asyncio

print(pytest_asyncio.__version__)

Installation

pip (standard)

pip install pytest-asyncio

Virtual environment (recommended)

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

pip3

pip3 install pytest-asyncio

conda

conda install -c conda-forge pytest-asyncio

Poetry

poetry add pytest-asyncio

Dependencies

Installing pytest-asyncio will also install these packages:

Verify the Installation

After installing, confirm the package is available:

python -c "import pytest_asyncio; print(pytest_asyncio.__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 pytest-asyncio with pip.

ModuleNotFoundError: No module named 'pytest_asyncio'

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

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

ModuleNotFoundError: No module named 'pytest_asyncio' (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 pytest-asyncio to install into the interpreter you are running.

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

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

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

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 pytest-asyncio. 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 pytest-asyncio

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 pytest-asyncio

Recent Releases

VersionReleased
1.4.0a0 2026-03-25
1.3.0 latest 2025-11-10
1.1.1 2025-09-12
1.2.0 2025-09-12
1.1.0 2025-07-16

Full release history on PyPI →

Manage pytest-asyncio

Upgrade to latest version

pip install --upgrade pytest-asyncio

Install a specific version

pip install pytest-asyncio==1.3.0

Uninstall

pip uninstall pytest-asyncio

Check what is installed

pip show pytest-asyncio

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