How to Install httpx in Python

v0.28.1 Web & HTTP Python >=3.8 BSD-3-Clause

The next generation HTTP client.

Install pip install httpx

What is httpx?

The next generation HTTP client.

HTTPX - A next-generation HTTP client for Python.

HTTPX is a fully featured HTTP client library for Python 3. It includes an integrated command line client, has support for both HTTP/1.1 and HTTP/2, and provides both sync and async APIs.

Which now allows us to use HTTPX directly from the command-line...

Quick Start

Minimal example to get started with httpx:

import httpx

# Synchronous
r = httpx.get("https://api.github.com")
print(r.status_code)

# Async
import asyncio

async def main():
    async with httpx.AsyncClient() as client:
        r = await client.get("https://api.github.com")
        print(r.json())

asyncio.run(main())

Installation

pip (standard)

pip install httpx

Virtual environment (recommended)

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

pip3

pip3 install httpx

conda

conda install -c conda-forge httpx

Poetry

poetry add httpx

Dependencies

Installing httpx will also install these packages:

Verify the Installation

After installing, confirm the package is available:

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

ModuleNotFoundError: No module named 'httpx'

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

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

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

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

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

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

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

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 httpx

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

Recent Releases

VersionReleased
1.0.dev3 2025-09-15
1.0.dev2 2025-08-04
1.0.dev1 2025-07-02
0.28.1 latest 2024-12-06
0.28.0 2024-11-28

Full release history on PyPI →

Manage httpx

Upgrade to latest version

pip install --upgrade httpx

Install a specific version

pip install httpx==0.28.1

Uninstall

pip uninstall httpx

Check what is installed

pip show httpx

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