ImportError: cannot import name connections
ImportError: cannot import name connections
我想在我的 Django 应用程序中包含全文搜索。我正在为 this.When 使用 whoosh-haystack 我在安装的应用程序中包含 whoosh 和 haystack,并执行命令 ./manage.py
,我收到导入错误。谁能解决这个问题。
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'whoosh',
'haystack',
'galleryApp',
'galleryAdmin',
]
我得到的错误是
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/haystack/admin.py", line 13, in <module>
from haystack import connections
ImportError: cannot import name connections
包 haystack
有冲突 django-haystack
。
(重新)移动它将解决问题。
详情见chat。
检查 __init__.py
文件是否在 python sitepackages/haystack
文件夹中。这可能是由于缺少 __init__.py
。 __init__.py
具有连接属性。如果不可用,请尝试卸载并 install/manually 从 github 源写入 __init__.py
文件。
以上对我不起作用。
对我有用的是:
pip uninstall haystack
pip uninstall django-haystack
pip install django-haystack
我想在我的 Django 应用程序中包含全文搜索。我正在为 this.When 使用 whoosh-haystack 我在安装的应用程序中包含 whoosh 和 haystack,并执行命令 ./manage.py
,我收到导入错误。谁能解决这个问题。
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'whoosh',
'haystack',
'galleryApp',
'galleryAdmin',
]
我得到的错误是
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/haystack/admin.py", line 13, in <module>
from haystack import connections
ImportError: cannot import name connections
包 haystack
有冲突 django-haystack
。
(重新)移动它将解决问题。
详情见chat。
检查 __init__.py
文件是否在 python sitepackages/haystack
文件夹中。这可能是由于缺少 __init__.py
。 __init__.py
具有连接属性。如果不可用,请尝试卸载并 install/manually 从 github 源写入 __init__.py
文件。
以上对我不起作用。
对我有用的是:
pip uninstall haystack
pip uninstall django-haystack
pip install django-haystack