I am new to python and I am trying to experience with python and elasticsearch.
I installed python by installing homebrew and running:
brew install python
This also installed pip. Then when I had pip I ran:
pip install elasticsearch
This installed elasticsearch. However, When I run the script below:
from elasticsearch import Elasticsearch
es = elasticsearch()
print("hello")
It tells me the following:
File "script.py", line 1, in <module>
from elasticsearch import Elasticsearch
ImportError: No module named elasticsearch
Can anyone offer any guidance as to what the issue is?
What is ElasticSearch? ElasticSearch (ES) is a distributed and highly available open-source search engine that is built on top of Apache Lucene. It's an open-source which is built in Java thus available for many platforms. You store unstructured data in JSON format which also makes it a NoSQL database.
OPTION 1: Check Version using Curl from Command Line In this example, Elasticsearch is running locally on the default port so our HTTP request will be to http://localhost:9200 . If Elasticsearch was running on a different server your HTTP request would take the form http://YOURDOMAIN.com:9200 .
If you've installed through pip, set/export below environment variable--
export PYTHONPATH=/usr/local/lib/python2.7/site-packages
For pyCharm, just add PYTHONPATH=/usr/local/lib/python2.7/site-packages; in Environment variables. You can reach to this setting by "Run-> Edit Configuration". Click apply and it should work fine.
You should capitalize the 'elasticsearch()'
Quoting from es-python
# by default we connect to localhost:9200
es = Elasticsearch()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With