python-elasticsearch-logger icon indicating copy to clipboard operation
python-elasticsearch-logger copied to clipboard

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

Open ffMathy opened this issue 1 year ago • 5 comments

I am getting the following error when I try to use the package:

File "/usr/local/lib/python3.7/site-packages/elasticecslogging/handlers.py", line 14, in from elasticsearch import Elasticsearch, RequestsHttpConnection ImportError: cannot import name 'RequestsHttpConnection' from 'elasticsearch' (/usr/local/lib/python3.7/site-packages/elasticsearch/init.py)

Here's my requirements.txt:

ftrack-python-api==2.3.0
ElasticECSHandler==1.0.3
elasticsearch==8.6.2
requests==2.28.2

ffMathy avatar Mar 10 '23 13:03 ffMathy

Hi,

As a quick W/A I have set elasticsearch to last 7.x version in PR #92.

Another, local W/A is to call:

pip uninstall elasticsearch
pip install elasticsearch==7.17.9

thoscilo avatar Mar 28 '23 10:03 thoscilo

Hi @ffMathy

Did the recommended workaround from @thoscilo help?

drumadrian avatar Apr 02 '23 03:04 drumadrian

I can't downgrade to 7 unfortunately.

ffMathy avatar Apr 02 '23 08:04 ffMathy

@ffMathy, @drumadrian - I have managed locally fix this problem and update the usage of elasticsearch in version 8.X and successfully ingested logs to my ELK stack.

Right now I was able to test it with my custom auth method (LDAP with login and password provided directly - in plans to add as new PR too).

I will test other auth methods and create fix PR with result's.

thoscilo avatar Apr 03 '23 20:04 thoscilo

@ffMathy, @drumadrian - you can check the #93 PR. It should fix the original problem reported.

thoscilo avatar Apr 06 '23 21:04 thoscilo