Consistently getting ImportError: Could not import settings 'myapp.settings' error

前端 未结 1 1730
终归单人心
终归单人心 2021-02-20 12:01

There appears to be a number of potential solutions to this problem but nothing seems to work for me.

Running python manage.py runserver is fine but I get t

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-20 12:36

    Try:

    export PYTHONPATH=/path/to/folder/with/manage.py:$PYTHONPATH
    

    It seems like it is a path problem. the path from where you call manage.py is usually added to PYTHONPATH, if you call django-admin.py it is not. Your application therefore does not find the ram module. You need to add the folder where your manage.py resides to PYTHONPATH

    EDIT

    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.

    Means you have to tell django, which settings. So enter the following line

    export DJANGO_SETTINGS_MODULE='ram.settings'
    

    or start django-admin the following way

    django-admin.py runserver --settings='ram.settings'
    

    (With the changed pythonpath, of course)

    0 讨论(0)
提交回复
热议问题