Error: The 'elasticsearch' backend requires the installation of 'requests'. How do I fix it?
Asked Answered
P

3

7

I´m having a issue when I ran "python manage.py rebuild_index" in my app supported by haystack and elasticsearch.

Python 2.7 Django version 1.6.2 Haystack 2.1.0 Elasticsearch 1.0

Please see the error that is appearing:

Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/lib/python2.7/site-packages/django/core/management/init.py", line 399, in > execute_from_command_line utility.execute() File "/usr/lib/python2.7/site-packages/django/core/management/init.py", line 392, in > execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 242, in >run_from_argv self.execute(*args, **options.dict) File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute output = self.handle(*args, **options) File "/usr/lib/python2.7/site-packages/haystack/management/commands/rebuild_index.py", line 15, in handle call_command('clear_index', **options) File "/usr/lib/python2.7/site-packages/django/core/management/init.py", line 159, in call_command return klass.execute(*args, **defaults) File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute output = self.handle(*args, **options) File "/usr/lib/python2.7/site-packages/haystack/management/commands/clear_index.py", line 48, in handle backend = connections[backend_name].get_backend() File "/usr/lib/python2.7/site-packages/haystack/utils/loading.py", line 98, in getitem self._connections[key] = load_backend(self.connections_info[key]['ENGINE'])(using=key) File "/usr/lib/python2.7/site-packages/haystack/utils/loading.py", line 51, in load_backend return import_class(full_backend_path) File "/usr/lib/python2.7/site-packages/haystack/utils/loading.py", line 18, in import_class module_itself = importlib.import_module(module_path) File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module import(name) File "/usr/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 21, in raise MissingDependency("The 'elasticsearch' backend requires the installation of 'requests'.") haystack.exceptions.MissingDependency: The 'elasticsearch' backend requires the installation of 'requests'.

I've installed all the packages needed to run those apps however is asking about requests, What is it about?

Palsy answered 14/3, 2014 at 17:36 Comment(2)
BTW How you have installed django-haystack?Liz
Are you certain that requests is installed? Try running pip install requests. Also, if you aren't running this in a virtualenv, might be a good idea so you can better manage dependencies and avoid conflicts across projects.Francoise
L
2

If you just install requests module through pip this error should go away.

Liz answered 14/3, 2014 at 17:55 Comment(2)
Unfortunalty requests is installed (even uninstalled/reinstalled in virtualenv to make sure), and it still don't work.Tackett
Should have been problem with virtualenv. Make sure the environment is activated or you should install requests where the haystack is installed.Liz
M
24

just do

pip install pyelasticsearch
Mumps answered 6/7, 2014 at 12:25 Comment(1)
This trick worked for me. Aforementioned command installed following packages: Installing collected packages: certifi, urllib3, elasticsearch, simplejson, six, pyelasticsearch So problem must be due to missing dependecies ( urllib3 I strongly suspect)Rior
L
2

If you just install requests module through pip this error should go away.

Liz answered 14/3, 2014 at 17:55 Comment(2)
Unfortunalty requests is installed (even uninstalled/reinstalled in virtualenv to make sure), and it still don't work.Tackett
Should have been problem with virtualenv. Make sure the environment is activated or you should install requests where the haystack is installed.Liz
O
0

pip install "elasticsearch>=7,<8"

Oleviaolfaction answered 29/5, 2023 at 6:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.