# Python: ImportError: cannot import name 'E' from 'elasticsearch.esql'

**URL:** <https://discuss.elastic.co/t/python-importerror-cannot-import-name-e-from-elasticsearch-esql/381204>\
**Category:** Elasticsearch\
**Tags:** language-clients, esql\
**Created:** [August 21, 2025, 11:41am UTC](https://discuss.elastic.co/t/python-importerror-cannot-import-name-e-from-elasticsearch-esql/381204 "2025-08-21T11:41:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter9](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter9/32/144671_2.png) [@peter9](https://discuss.elastic.co/u/peter9)\
**Post date:** [August 21, 2025, 11:41am UTC](https://discuss.elastic.co/t/python-importerror-cannot-import-name-e-from-elasticsearch-esql/381204/1 "2025-08-21T11:41:07Z")

</div>

I am reading the docs at [ES|QL Query Builder | Python](https://www.elastic.co/docs/reference/elasticsearch/clients/python/esql-query-builder)

There are examples that start with:

```auto
from elasticsearch.esql import ESQL, E

```

When I try these, I get:

```auto
ImportError: cannot import name 'E' from 'elasticsearch.esql' 

```

I need this to preventing injection attacks. How do I fix this?

- Elasticsearch version 9.1.2
- Python Elasticsearch version 9.1.0
- Python version 3.10.18

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [August 21, 2025, 12:16pm UTC](https://discuss.elastic.co/t/python-importerror-cannot-import-name-e-from-elasticsearch-esql/381204/3 "2025-08-21T12:16:52Z")

</div>

Hello @peter9

As per 9.0+ documentation : [ES|QL Query Builder | Python](https://www.elastic.co/docs/reference/elasticsearch/clients/python/esql-query-builder)

_This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features._

We do not see any E function in the elasticsearch.esql :

```auto
Name: elasticsearch
Version: 9.1.0
Summary: Python client for Elasticsearch
>>> import elasticsearch.esql
>>> print(dir(elasticsearch.esql))
['ESQL', ' __builtins__', ' __cached__', ' __doc__', ' __file__', ' __loader__', ' __name__', ' __package__', ' __path__', ' __spec__', 'and_', 'esql', 'not_', 'or_']

```

Same example is not available in 8.19 documentation :

> **[Creating an ES|QL query | Elasticsearch Python Client \[8.19\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/_creating_an_esql_query.html)**

Thanks!!

---

<div class="post-metadata">

**Author:** ![gare](https://avatars.discourse-cdn.com/v4/letter/g/c6cbf5/32.png) [@gare](https://discuss.elastic.co/u/gare)\
**Post date:** [August 28, 2025, 9:01pm UTC](https://discuss.elastic.co/t/python-importerror-cannot-import-name-e-from-elasticsearch-esql/381204/4 "2025-08-28T21:01:43Z")

</div>

Hi @Tortoise

The E function is referenced in the 8.19 documentation on the following pages:

> **[Creating ES|QL Expressions and Conditions | Elasticsearch Python Client \[8.19\]...](https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/_creating_esql_expressions_and_conditions.html)**

> **[Using ES|QL functions | Elasticsearch Python Client \[8.19\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/_using_esql_functions.html)**

I am currently running into this import issue on 8.19 as I would like to use ESQL for safe querying.

---

<div class="post-metadata">

**Author:** ![gare](https://avatars.discourse-cdn.com/v4/letter/g/c6cbf5/32.png) [@gare](https://discuss.elastic.co/u/gare)\
**Post date:** [August 29, 2025, 1:02pm UTC](https://discuss.elastic.co/t/python-importerror-cannot-import-name-e-from-elasticsearch-esql/381204/5 "2025-08-29T13:02:01Z")

</div>

@Tortoise @peter9 It looks like E can be imported from dsl:

```auto
>>> from elasticsearch.dsl import E

```
