我正在尝试将Django和Haystack与Elasticsearch一起用作Ubuntu 14.04的后端。我安装了Elasticsearch和Haystack。
运行python manage.py runserver时收到的错误:
me@ubuntu:$ python manage.py runserver
Validating models...
0 errors found
January 31, 2015 - 17:40:37
Django version 1.5.4, using settings 'website_project.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "/home/me/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/handlers.py", line 72, in __call__
return self.application(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 243, in __call__
signals.request_started.send(sender=self.__class__)
File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 170, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python2.7/dist-packages/haystack/__init__.py", line 60, in reset_search_queries
for conn in connections.all():
File "/usr/local/lib/python2.7/dist-packages/haystack/utils/loading.py", line 111, in all
return [self[alias] for alias in self.connections_info]
File "/usr/local/lib/python2.7/dist-packages/haystack/utils/loading.py", line 99, in __getitem__
self._connections[key] = load_backend(self.connections_info[key]['ENGINE'])(using=key)
File "/usr/local/lib/python2.7/dist-packages/haystack/utils/loading.py", line 52, in load_backend
return import_class(full_backend_path)
File "/usr/local/lib/python2.7/dist-packages/haystack/utils/loading.py", line 19, in import_class
module_itself = importlib.import_module(module_path)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/haystack/backends/elasticsearch_backend.py", line 26, in <module>
raise MissingDependency("The 'elasticsearch' backend requires the installation of 'elasticsearch'. Please refer to the documentation.")
MissingDependency: The 'elasticsearch' backend requires the installation of 'elasticsearch'. Please refer to the documentation.
我的PYTHONPATH
home/me/.pythonbrew/pythons/Python-2.7.5/lib:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages
我在INSTALLED_APPS列表中有'haystack',并有以下配置:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
}
我可以用
启动Elasticsearchsudo service elasticsearch start
当我去http://localhost:9200/时 我明白了
{
"status" : 200,
"name" : "Stranger",
"version" : {
"number" : "1.1.1",
"build_hash" : "somehash",
"build_timestamp" : "2014-04-16T14:27:12Z",
"build_snapshot" : false,
"lucene_version" : "4.7"
},
"tagline" : "You Know, for Search"
}
好像我安装了Elasticsearch所以我不知道为什么我会得到
MissingDependency: The 'elasticsearch' backend requires the installation of 'elasticsearch'. Please refer to the documentation.
错误。
答案 0 :(得分:5)
似乎你已经修好了它,但是对于未来的Google员工:some people在2014年至2015年期间遇到干草堆版本问题。将版本修复为2.1.0似乎可以修复它,直接从git下载2.4.0:
pip install git+https://github.com/django-haystack/django-haystack
更新:pypi的当前版本的haystack工作(2015年11月),请务必更新!