Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Elasticsearch
✓ from elasticsearch9 import Elasticsearch
✗ from elasticsearch import Elasticsearch
elasticsearch is the deprecated client; always use elasticsearch9
helpers
✓ from elasticsearch9 import helpers
✗ from elasticsearch.helpers import scan
helpers are now under elasticsearch9, not elasticsearch
Create a client and ping the cluster. Uses environment variables for credentials.
import os
from elasticsearch9 import Elasticsearch
client = Elasticsearch(
os.environ.get('ELASTICSEARCH_URL', 'http://localhost:9200'),
api_key=os.environ.get('ELASTICSEARCH_API_KEY', ''),
verify_certs=False # For dev only
)
print(client.info())
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'elasticsearch'
You installed elasticsearch9 but tried importing from 'elasticsearch' (the old package).
fixUninstall both: pip uninstall elasticsearch elasticsearch9; then reinstall: pip install elasticsearch9
elasticsearch9.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPSConnection object ...) caused by: SSLError([SSL: CERTIFICATE_VERIFY_FAILED]
Default SSL verification fails against self-signed certificates.
fixAdd verify_certs=False to Elasticsearch constructor, or set SSL_CERT_FILE env variable.
elasticsearch9.exceptions.NotFoundError: NotFoundError(404, 'index_not_found_exception')
Trying to read/write to a non-existent index. Common when index name is misspelled or auto-creation is disabled.
fixCreate the index first: client.indices.create(index='my-index', ignore=400)
elasticsearch9.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'failed to parse field')
Sending a document with a field type that conflicts with the mapping.
fixUpdate the mapping or ensure the field value matches the expected type (e.g., integer for long field).
elasticsearch9.exceptions.AuthenticationException: AuthenticationException(401, 'security_exception')
Invalid credentials or API key. The old elasticsearch client used basic auth; elasticsearch9 requires explicit api_key parameter format.
fixEnsure you're passing api_key='id:api_key' or username/password via http_auth parameter.
Upgrade
Version history
9.4.1latest on PyPI · released May 26, 2026
Audit
Dependencies
elastic-transportrequiredHTTP transport layer (connection pools, retries)
certifirequiredCA bundle for TLS
urllib3optionalHTTP library