/ / Utilisation Whoosh / erreur avec django-haystack - django, django-haystack, whoosh

Whoosh utilisation / erreur avec django-haystack - django, django-haystack, whoosh

J'ai une application Django dans laquelle j'essaie d'utiliser django-haystack, donc suivi comme ci-dessous

Django-haystack installé

pip install django-haystack

installée Whoosh

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

Alors quand j'ai essayé pip freeze je peux voir la version de sortie comme Whoosh==2.5.6

Paramètres de la botte de foin Django

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

Et quand j'ai essayé d'exécuter le serveur, je vois le message d'erreur ci-dessous dans le navigateur

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.

Alors, comment résoudre l'erreur ci-dessus? pourquoi il demande Whoosh même si c'est déjà installé?

modifier

(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

Réponses:

1 pour la réponse № 1

Je vois que tu as un haystack module dans votre projet (/home/user/user/apps/proj-web/proj_name/haystack/). Supprimez ce dossier, activez votre virtualenv et exécutez:

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

pour être sûr que tout va bien.

Essayez ensuite de configurer votre botte de foin comme ceci:

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