python - Django no module named elasticsearch_dsl.connections -
i'm trying connect django model elasticsearch server on local host when try
from elasticsearch_dsl.connections import connections
i error "importerror: no module named elasticsearch_dsl.connections". when use same command in django shell, works fine.
search.py
from elasticsearch_dsl.connections import connections elasticsearch_dsl import doctype, text, date, boolean, integer, keyword, fields elasticsearch.helpers import bulk elasticsearch import elasticsearch .models import homegym, country, rating connections.create_connection() class homegymindex(doctype): title = text() price = fields.floatfield() tags = keyword() city = text() country = text() rate = integer() opusapproved = boolean() def bulk_indexing(): homegymindex.init() es = elasticsearch() bulk(client=es, actions=(b.indexing() b in homegym.objects.all().iterator()))
this leads importerror on line 1. "no module named elasticsearch_dsl.connections" same import statement works in shell though.
i've done pip install of elasticsearch , elasticsearch-dsl inside virtualenv.
here file structure
my_website/ elasticsearch/ #elasticsearch files pulled github elasticsearch-5.5.2-snapshot/ #elasticsearch files bin/ elasticsearch opus/ manage.py homegymlistings/ models.py search.py #other standard app files opus/ #standard files main django branch my_virtualenv/ bin/ activate
why import statement fail when called inside search.py file located inside homegymlistings app?
run this
pip install elasticsearch_dsl
Comments
Post a Comment