0

Installed pyes recently , but when i tired it in the python shell it is giving the error, Can any one please help me out in this regard:

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.
namit
  • 6,780
  • 4
  • 35
  • 41
Niranjan Sagar
  • 819
  • 1
  • 15
  • 17

1 Answers1

0

I found that this issue can be "worked around" by simply performing the following before running the script in Terminal

export DJANGO_SETTINGS_MODULE=default.settings

After running that code the script worked exactly the way it was supposed to!

  • Alternatively you can start a shell with your django environment loaded by running this from the directory containing your manage.py script: $ python manage.py shell – Dan Noble Apr 10 '13 at 15:33