'ElasticSearch ImportError: cannot import name 'Mapping' from 'elasticsearch.compat'

I get this import error when trying to run

from elasticsearch_dsl import Search, A

Full traceback

ImportError: cannot import name 'Mapping' from 'elasticsearch.compat' (C:\Users\SANA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\elasticsearch\compat.py)

elasticsearch version: 7.13.3 elasticsearch-dsl version: 7.4.0

I have tried:

from collections.abc import Mapping

And can't seem to google my way to an answer



Solution 1:[1]

You must have installed elasticsearch_dsl. Install elasticsearch-dsl.

Try doing :

pip uninstall elasticsearch_dsl
pip install elasticsearch-dsl 

this should work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shaurya Rohatgi