How to Install elasticsearch in Python

v9.3.0 General Purpose Python >=3.10

Python client for Elasticsearch

Install pip install elasticsearch

What is elasticsearch?

Python client for Elasticsearch

The official Python client for Elasticsearch.

Translating basic Python data types to and from JSON Configurable automatic discovery of cluster nodes Persistent connections Load balancing (with pluggable selection strategy) across available nodes Failed connection penalization (time based - failed connections won't be retried until a timeout is reached) Support for TLS and HTTP authentication Thread safety across requests Pluggable architecture Helper functions for idiomatically using APIs together

Download the latest version of Elasticsearch or sign-up for a free trial of Elastic Cloud.

Quick Start

Minimal example to get started with elasticsearch:

import elasticsearch

print(elasticsearch.__version__)

Installation

pip (standard)

pip install elasticsearch

Virtual environment (recommended)

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

pip3

pip3 install elasticsearch

conda

conda install -c conda-forge elasticsearch

Poetry

poetry add elasticsearch

Dependencies

Installing elasticsearch will also install these packages:

Verify the Installation

After installing, confirm the package is available:

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

ModuleNotFoundError: No module named 'elasticsearch'

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

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

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

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

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

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

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

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 elasticsearch

Recent Releases

VersionReleased
9.3.0 latest 2026-02-03
7.17.13 2026-01-12
9.0.5 2026-01-05
9.1.3 2026-01-05
8.19.3 2025-12-23

Full release history on PyPI →

Manage elasticsearch

Upgrade to latest version

pip install --upgrade elasticsearch

Install a specific version

pip install elasticsearch==9.3.0

Uninstall

pip uninstall elasticsearch

Check what is installed

pip show elasticsearch

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