0
votes

I have a django app in which i am trying to use django-haystack, so followed like below

Installed django-haystack

pip install django-haystack

Installed Whoosh

pip install Whoosh(https://bitbucket.org/mchaput/whoosh/wiki/Home)
            also tried
downloading from https://pypi.python.org/pypi/Whoosh/#downloads

So when i tried pip freeze i can able to see the output version as Whoosh==2.5.6

Django haystack settings

HAYSTACK_SITECONF = 'proj-web.search_sites'
HAYSTACK_SEARCH_ENGINE = 'whoosh'
HAYSTACK_WHOOSH_PATH = (os.path.join(os.path.dirname(__file__), 'search_index/'))

And when i tried to run the server i am seeing the below error message in browser

Traceback:
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  103.                     resolver_match = resolver.resolve(request.path_info)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
  319.             for pattern in self.url_patterns:
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
  347.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
  342.             self._urlconf_module = import_module(self.urlconf_name)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/home/user/user/apps/proj-web/proj_name/../proj_name/urls.py" in <module>
  66.   (r'^search/', include('search.urls')),
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/conf/urls/__init__.py" in include
  25.         urlconf_module = import_module(urlconf_module)
File "/home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/home/user/user/apps/proj-web/proj_name/search/urls.py" in <module>
  2. from proj_name.search.views import SiteSearch
File "/home/user/user/apps/proj-web/proj_name/../proj_name/search/views.py" in <module>
  2. from proj_name.haystack.views import SearchView
File "/home/user/user/apps/proj-web/proj_name/../proj_name/haystack/__init__.py" in <module>
  6. from haystack.sites import site
File "/home/user/user/apps/proj-web/proj_name/haystack/__init__.py" in <module>
  60. backend = load_backend(settings.HAYSTACK_SEARCH_ENGINE)
File "/home/user/user/apps/proj-web/proj_name/haystack/__init__.py" in load_backend
  35.         return __import__('haystack.backends.%s_backend' % backend_name, {}, {}, [''])
File "/home/user/user/apps/proj-web/proj_name/haystack/backends/whoosh_backend.py" in <module>
  28.     raise MissingDependency("The 'whoosh' backend requires the installation of 'Whoosh'. Please refer to the documentation.")

Exception Type: MissingDependency at /
Exception Value: The 'whoosh' backend requires the installation of 'Whoosh'. Please refer to the documentation.

So how to solve the above error ? why it is asking for Whoosh even though its already installed ?

Edit

(proj)user-ThinkPad-Edge-E430:~/home/user/apps/proj-web/ pip freeze
Django==1.5.5
MySQL-python==1.2.4
PIL==1.1.7
Pillow==2.2.2
South==0.8.4
**Whoosh==2.5.6**
argparse==1.2.1
django-appconf==0.6
django-compressor==1.3
django-haystack==2.1.0
django-mailer==0.1.0
django-pagination==1.0.7
django-tinymce==1.5.2
ipython==1.1.0
psycopg2==2.5.1
six==1.4.1
wsgiref==0.1.2
1
I see that you use a virtualenv. Is it possible that you didn't activate it before installing whoosh?Reto Aebersold
no actually i double checked, i am in my virtual env and isntalled whoosh inside virtualenv, i can see that, see above editShiva Krishna Bavandla
try doing import whoosh inside ./manage.py shell, what happens?Lie Ryan

1 Answers

1
votes

I see that you have a haystack module in your project (/home/user/user/apps/proj-web/proj_name/haystack/). Remove this folder, activate your virtualenv and run:

pip uninstall django-haystack && pip install django-haystack

to be sure everything is ok.

Then try to configure your haystack like this:

import os
HAYSTACK_CONNECTIONS = {
  'default': {
    'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
    'PATH': os.path.join(os.path.dirname(__file__), 'search_index'),
  },
}