ImportError: Could not import settings 'openstack_dashboard.settings'

Asked by Imad Benbrahim

Hello,

I installed OpenStack, including dashboard on a linux machine following the instructions in docs.openstack.org
(specifically http://docs.openstack.org/havana/install-guide/install/yum/content/install_dashboard.html)

But the apache web server doesn’t work properly when I access the “dashboard” component using http://localhost/dashboard. I get “500 Internal Server Error”. And the httpd log indicates:
             mod_wsgi (pid=34193): Exception occurred processing WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
             . . .
             File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in __init__
ImportError: Could not import settings 'openstack_dashboard.settings' (Is it on sys.path?)

The file django.wsi has:
    sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '../..'))
    os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'
Also There is a file /usr/share/openstack-dashboard/openstack_dashboard/settings.py and a file __init__.py so I’m not sure why it is complaining…

Currently my /etc/openstack-dashboard/ directory has 3 files: keystone_policy.json local_settings nova_policy.json
And my directory /usr/share/openstack-dashboard has 5 files: manage.py manage.pyc manage.pyo openstack_dashboard static
Directory /usr/share/openstack-dashboard/openstack_dashboard has several files including settings.py, settings.pyc, settings.pyo, __init__.py ...

Thanks for the help

11/20/2013 11am addition:
I am using a RedHat 6.4 machine and I followed the instructions in http://docs.openstack.org/havana/install-guide/install/yum/content/install_dashboard.html to install dashboard. I installed keystone, glance and nova using yum.
I already have ALLOWED_HOSTS=['10.160.20.161', 'localhost'] in /etc/openstack-dashboard/local_settings
Here is what I see in /var/log/httpd/error_log :

[Wed Nov 20 11:16:33 2013] [error] [client ::1] mod_wsgi (pid=37278): Exception occurred processing WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi'.
[Wed Nov 20 11:16:33 2013] [error] [client ::1] Traceback (most recent call last):
[Wed Nov 20 11:16:33 2013] [error] [client ::1] File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Wed Nov 20 11:16:33 2013] [error] [client ::1] self.load_middleware()
[Wed Nov 20 11:16:33 2013] [error] [client ::1] File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 39, in load_middleware
[Wed Nov 20 11:16:33 2013] [error] [client ::1] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Wed Nov 20 11:16:33 2013] [error] [client ::1] File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in inner
[Wed Nov 20 11:16:33 2013] [error] [client ::1] self._setup()
[Wed Nov 20 11:16:33 2013] [error] [client ::1] File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in _setup
[Wed Nov 20 11:16:33 2013] [error] [client ::1] self._wrapped = Settings(settings_module)
[Wed Nov 20 11:16:33 2013] [error] [client ::1] File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in __init__
[Wed Nov 20 11:16:33 2013] [error] [client ::1] raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Wed Nov 20 11:16:33 2013] [error] [client ::1] ImportError: Could not import settings 'openstack_dashboard.settings' (Is it on sys.path?): No module named pbr.version

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Dashboard (Horizon) Edit question
Assignee:
No assignee Edit question
Solved by:
Matthias Runge
Solved:
Last query:
Last reply:
Revision history for this message
Matthias Runge (mrunge) said :
#1

There is a common issue with ALLOWED_HOSTS setting. Please be sure to include localhost in the list as well.

If that doesn't solve your issue, please provide more info: version you're using, where did you get the files etc....

More logs would be great, too!

Revision history for this message
Imad Benbrahim (ibenbrahim) said :
#2

Please see the addition titled " 11/20/2013 11am addition:" in the question.

Imad Benbrahim

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Matthias Runge
Sent: Wednesday, November 20, 2013 10:06 AM
To: Benbrahim, Imad
Subject: Re: [Question #239533]: ImportError: Could not import settings 'openstack_dashboard.settings'

Your question #239533 on OpenStack Dashboard (Horizon) changed:
https://answers.launchpad.net/horizon/+question/239533

    Status: Open => Answered

Matthias Runge proposed the following answer:
There is a common issue with ALLOWED_HOSTS setting. Please be sure to include localhost in the list as well.

If that doesn't solve your issue, please provide more info: version you're using, where did you get the files etc....

More logs would be great, too!

--
If this answers your question, please go to the following page to let us know that it is solved:
https://answers.launchpad.net/horizon/+question/239533/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the following page to enter your feedback:
https://answers.launchpad.net/horizon/+question/239533

You received this question notification because you asked the question.

Revision history for this message
Best Matthias Runge (mrunge) said :
#3

ok, now that we have the full log:
yum install python-pbr && service httpd restart

Please note, your httpd seems to listen on ipv6. IPv6 is unsupported on OpenStack.

Revision history for this message
Imad Benbrahim (ibenbrahim) said :
#4

Thank very much! yum install python-pbr followed by service httpd restart solved this problem.

But when I try to login I get an authentication error. In the browser I get "An error occurred authenticating. Please try again later." and in the logs:
/var/log/httpd/error_log:
    [Wed Nov 20 21:00:52 2013] [error] REQ: curl -i -X POST http://localhost:5000/v2.0/tokens -H "Content-Type: application/json" -H "User-Agent: python-keystoneclient"
    [Wed Nov 20 21:00:52 2013] [error] REQ BODY: {"auth": {"passwordCredentials": {"username": "admin", "password": "admin"}}}
    [Wed Nov 20 21:00:52 2013] [error]
    [Wed Nov 20 21:00:52 2013] [error] INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost
    [Wed Nov 20 21:00:52 2013] [error] Login failed for user "admin".

/var/log/access_log:
    127.0.0.1 - - [20/Nov/2013:16:10:25 -0500] "POST /dashboard/auth/login/ HTTP/1.1" 200 1700 "http://localhost/dashboard/auth/login/" "Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131023 Firefox/17.0"
    127.0.0.1 - - [20/Nov/2013:16:10:26 -0500] "GET /dashboard/i18n/js/horizon/ HTTP/1.1" 200 718 "http://localhost/dashboard/auth/login/" "Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131023 Firefox/17.0

keystone.log remains unchanged.

My /etc/openstack-dashboard/local_settings :
import os
from django.utils.translation import ugettext_lazy as _
from openstack_dashboard import exceptions
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = ['10.160.20.161', 'localhost']
HORIZON_CONFIG = {
    'dashboards': ('project', 'admin', 'settings',),
    'default_dashboard': 'project',
    'user_home': 'openstack_dashboard.views.get_user_home',
    'ajax_queue_limit': 10,
    'auto_fade_alerts': {
        'delay': 3000,
        'fade_duration': 1500,
        'types': ['alert-success', 'alert-info']
    },
    'help_url': "http://docs.openstack.org",
    'exceptions': {'recoverable': exceptions.RECOVERABLE,
                   'not_found': exceptions.NOT_FOUND,
                   'unauthorized': exceptions.UNAUTHORIZED},
}
from horizon.utils import secret_key
LOCAL_PATH = '/var/lib/openstack-dashboard'
SECRET_KEY = secret_key.generate_or_read_from_file(os.path.join(LOCAL_PATH, '.secret_key_store'))
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
CACHES = {
    'default': {
        'BACKEND' : 'django.core.cache.backends.locmem.LocMemCache'
    }
}
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

OPENSTACK_HOST = "localhost"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v2.0" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "admin"
OPENSTACK_KEYSTONE_BACKEND = {
    'name': 'native',
    'can_edit_user': True,
    'can_edit_group': True,
    'can_edit_project': True,
    'can_edit_domain': True,
    'can_edit_role': True
}

OPENSTACK_HYPERVISOR_FEATURES = {
    'can_set_mount_point': False,

    # NOTE: as of Grizzly this is not yet supported in Nova so enabling this
    # setting will not do anything useful
    'can_encrypt_volumes': False
}
OPENSTACK_NEUTRON_NETWORK = {
    'enable_lb': False,
    'enable_firewall': False,
    'enable_quotas': True,
    'enable_vpn': False,
    # The profile_support option is used to detect if an external router can be
    # configured via the dashboard. When using specific plugins the
    # profile_support can be turned on if needed.
    'profile_support': None,
    #'profile_support': 'cisco',
}
API_RESULT_LIMIT = 1000
API_RESULT_PAGE_SIZE = 20
TIME_ZONE = "UTC"
POLICY_FILES_PATH = '/etc/openstack-dashboard'
POLICY_FILES = {
    'identity': 'keystone_policy.json',
    'compute': 'nova_policy.json'
}

Revision history for this message
Imad Benbrahim (ibenbrahim) said :
#5

I disabled SELinux and rebooted and I no longer have the autentication issue. While this might not be my fnal solution, I can make progress now.

Revision history for this message
Imad Benbrahim (ibenbrahim) said :
#6

Thanks Matthias Runge, that solved my question.

Revision history for this message
Adrian Vladu (avladu) said :
#7

pip install pbr solved my problem also.

Revision history for this message
Matthias Runge (mrunge) said :
#8

In a distribution you never should use pip install, because pip installed packages won't see any updates through the distribution.