Note that there are some explanatory texts on larger screens.

plurals
  1. POConsistently getting ImportError: Could not import settings 'myapp.settings' error
    primarykey
    data
    text
    <p>There appears to be a number of potential solutions to this problem but nothing seems to work for me.</p> <p>Running <code>python manage.py runserver</code> is fine but I get the error when trying to run <code>django-admin.py</code> - with any option. I am actually trying to do a <code>django-admin.py dumpdata myapp</code>.</p> <pre><code>Traceback (most recent call last): File "/Users/lemon/.virtualenvs/ram/bin/django-admin.py", line 5, in &lt;module&gt; management.execute_from_command_line() File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command commands = get_commands() File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands apps = settings.INSTALLED_APPS File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__ self._setup(name) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup self._wrapped = Settings(settings_module) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__ % (self.SETTINGS_MODULE, e) ImportError: Could not import settings 'ram.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named ram.settings </code></pre> <p>Structure of my project directory is:</p> <pre><code>README.md ├── TODO ├── fabfile.py ├── manage.py ├── ram │   ├── __init__.py │   ├── __init__.pyc │   ├── ram.sqlite │   ├── ram.sqlite.orig │   ├── settings.py │   ├── settings.py.orig │   ├── settings.pyc │   ├── templates │   ├── urls.py │   ├── urls.pyc │   ├── wsgi.py │   └── wsgi.pyc ├── ramapp │   ├── __init__.py │   ├── __init__.pyc │   ├── admin.py │   ├── admin.pyc │   ├── forms.py │   ├── forms.pyc │   ├── models.py │   ├── models.pyc │   ├── templates │   │   └── ram │   │   ├── contributors.html │   │   ├── index.html │   │   ├── ram_sheet.html │   │   └── scenario_add.html │   ├── tests.py │   ├── urls.py │   ├── urls.pyc │   ├── views.py │   ├── views.py.orig │   └── views.pyc ├── requirements.txt └── templates └── admin └── base_site.html </code></pre> <p>I'm using virtualenvrapper which I have reinstalled and have no issue with.</p> <p><code>manage.py</code> looks like this:</p> <pre><code>#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ram.settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv) </code></pre> <p>Not quite sure where else to go with this - any help massively appreciated. Thanks.</p> <p>Having tried to amend the <code>PYTHONPATH</code> as suggested, now get similar error:</p> <pre><code>Traceback (most recent call last): File "/Users/lemon/.virtualenvs/ram/bin/django-admin.py", line 5, in &lt;module&gt; management.execute_from_command_line() File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command klass = load_command_class(app_name, subcommand) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module __import__(name) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/management/commands/dumpdata.py", line 3, in &lt;module&gt; from django.core import serializers File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/serializers/__init__.py", line 22, in &lt;module&gt; from django.core.serializers.base import SerializerDoesNotExist File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/serializers/base.py", line 5, in &lt;module&gt; from django.db import models File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/db/__init__.py", line 83, in &lt;module&gt; signals.request_started.connect(reset_queries) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 88, in connect if settings.DEBUG: File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__ self._setup(name) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/conf/__init__.py", line 47, in _setup % (desc, ENVIRONMENT_VARIABLE)) django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload