How to Install aiohttp in Python

v3.13.5 Web & HTTP Python >=3.9 Apache-2.0 AND MIT

Async http client/server framework (asyncio)

Install pip install aiohttp

What is aiohttp?

Async http client/server framework (asyncio)

- Supports both client and server side of HTTP protocol. - Supports both client and server Web-Sockets out-of-the-box and avoids Callback Hell. - Provides Web-server with middleware and pluggable routing.

async with aiohttp.ClientSession() as session: async with session.get(' as response:

print("Status:", response.status) print("Content-type:", response.headers['content-type'])

Quick Start

Minimal example to get started with aiohttp:

import aiohttp
import asyncio

async def fetch():
    async with aiohttp.ClientSession() as session:
        async with session.get("https://api.github.com") as r:
            data = await r.json()
            print(data["current_user_url"])

asyncio.run(fetch())

Installation

pip (standard)

pip install aiohttp

Virtual environment (recommended)

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

pip3

pip3 install aiohttp

conda

conda install -c conda-forge aiohttp

Poetry

poetry add aiohttp

Dependencies

Installing aiohttp will also install these packages:

Verify the Installation

After installing, confirm the package is available:

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

ModuleNotFoundError: No module named 'aiohttp'

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

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

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

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

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

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

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 aiohttp. 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 aiohttp

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 aiohttp

ConnectionError: Failed to establish a new connection

Cause: Server unreachable, URL invalid, or firewall/proxy blocking the connection.

Fix: Verify the URL and network access. Set HTTP_PROXY / HTTPS_PROXY env vars if behind a proxy.

SSLError: CERTIFICATE_VERIFY_FAILED

Cause: The remote server's SSL certificate cannot be verified.

Fix: Update CA certificates on your system. For testing only, disable SSL verification (never in production).

Runtime Errors

Common errors when using aiohttp after installation.

aiohttp.ClientConnectorError: Cannot connect to host

Cause: Server unreachable or URL incorrect.

Fix: Verify the URL and check network connectivity. Ensure the server is running if testing locally.

RuntimeError: Session is closed

Cause: The ClientSession was used after being closed.

Fix: Use async with aiohttp.ClientSession() as session: to manage the session lifecycle.

Recent Releases

VersionReleased
3.13.5 latest 2026-03-31
3.13.4 2026-03-28
3.13.3 2026-01-03
3.13.2 2025-10-28
3.13.1 2025-10-17

Full release history on PyPI →

Manage aiohttp

Upgrade to latest version

pip install --upgrade aiohttp

Install a specific version

pip install aiohttp==3.13.5

Uninstall

pip uninstall aiohttp

Check what is installed

pip show aiohttp

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