【问题标题】:python elastic search not working pyes package issuespython弹性搜索不起作用pyes包问题
【发布时间】:2013-04-10 22:44:52
【问题描述】:

最近安装了pyes,但是当我在python shell中厌倦它时,它给出了错误, 任何人都可以在这方面帮助我:

Traceback (most recent call last):

File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pyes-0.19.1-py2.7.egg/pyes/__init__.py", line 41, in <module>
    from .djangoutils import *
File "/usr/local/lib/python2.7/dist-packages/pyes-0.19.1-py2.7.egg/pyes/djangoutils.py", line 6, in <module>
    from django.db import models
  File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 11, in <module>
    if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 52, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 45, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

【问题讨论】:

    标签: python elasticsearch pyes


    【解决方案1】:

    我发现这个问题可以通过在终端中运行脚本之前简单地执行以下操作来“解决”

    export DJANGO_SETTINGS_MODULE=default.settings
    

    运行该代码后,脚本完全按照预期的方式运行!

    【讨论】:

    • 另外,您可以通过从包含您的 manage.py 脚本的目录运行它来启动一个加载了您的 django 环境的 shell:$ python manage.py shell
    猜你喜欢
    • 2023-03-18
    • 2012-08-18
    • 2021-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多