How to Install anthropic in Python

v0.94.0 General Purpose Python >=3.9 MIT

The official Python library for the anthropic API

Install pip install anthropic

What is anthropic?

The official Python library for the anthropic API

The Claude SDK for Python provides access to the Claude API from Python applications.

Full documentation is available at platform.claude.com/docs/en/api/sdks/python.

This project is licensed under the MIT License. See the LICENSE file for details.

Quick Start

Minimal example to get started with anthropic:

import anthropic

client = anthropic.Anthropic()  # uses ANTHROPIC_API_KEY env var

message = client.messages.create(
    model="claude-opus-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude!"}]
)
print(message.content[0].text)

Installation

pip (standard)

pip install anthropic

Virtual environment (recommended)

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

pip3

pip3 install anthropic

conda

conda install -c conda-forge anthropic

Poetry

poetry add anthropic

Dependencies

Installing anthropic will also install these packages:

Verify the Installation

After installing, confirm the package is available:

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

ModuleNotFoundError: No module named 'anthropic'

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

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

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

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

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

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

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

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 anthropic

Runtime Errors

Common errors when using anthropic after installation.

anthropic.AuthenticationError

Cause: The API key is missing or invalid.

Fix: Set the ANTHROPIC_API_KEY environment variable or pass api_key='...' to Anthropic().

anthropic.RateLimitError

Cause: API rate limit exceeded.

Fix: Add exponential backoff between requests. Reduce request frequency or upgrade to a higher rate limit tier.

Recent Releases

VersionReleased
0.94.0 latest 2026-04-10
0.93.0 2026-04-09
0.92.0 2026-04-08
0.90.0 2026-04-07
0.91.0 2026-04-07

Full release history on PyPI →

Manage anthropic

Upgrade to latest version

pip install --upgrade anthropic

Install a specific version

pip install anthropic==0.94.0

Uninstall

pip uninstall anthropic

Check what is installed

pip show anthropic

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