0

Following this not so popular question: OpenStack & NGINX+uWSGI

I've start to build my dashboard node using well... NGINX and uWSGI of course, but I'm now facing a path problem.

Indeed, uWSGI is correctly launching the processes and NGINX is correctly connected to it.

BUT, as soon as I try to retrieve the dashboard main page, NGINX is throwing a 503 Error page and my uWSGI Instance yeld me this error message:

ImportError: Could not import settings 'openstack_dashboard.settings' (Is it on sys.path?): No module named openstack_dashboard.settings

This is not the full stack but the revelant part of it.

About me, it's just a matter of PythonPath, but the point is that I don't know how to solve this problem.

Indeed, I now that the PythonPath is an env variable, and I already set one like this on my root user:

export PYTHONPATH='/srv/www/openstack-dashboard/'

Now, my problem is that it seems that this env variable is not detect or not use by python because uWSGI continue to crash with the following complete stack:

Traceback (most recent call last):
   File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in  __call__
self.load_middleware()
   File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
   for middleware_path in settings.MIDDLEWARE_CLASSES:
  File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner
self._setup()
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 95, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))

ImportError: Could not import settings 'openstack_dashboard.settings' (Is it on sys.path?): No module named openstack_dashboard.settings

[pid: 31409|app: 0|req: 1/1] 172.21.150.91 () {36 vars in 556 bytes} [Mon Apr  8 11:02:35 2013] GET / => generated 0 bytes in 1 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

So, if anyone has a clue to the way to solve this, I'll be glade to read it ;-)

Dr I
  • 943
  • 16
  • 33

1 Answers1

1

You should invest a bit of time in understanding how the pythonpath works, this is vital for mastering python (and obviously django). For example you added /srv/www/openstack-dashboard/ to your pythonpath (i assume you have set the variable in the right place), so when asking for openstack-dashboard.settings python will search for /srv/www/openstack-dashboard/openstack-dashboard/settings.py. In addition to this i suggest you to read the official uWSGI 'WSGI Quickstart', as it reports how to deploy both old and new Django versions.

roberto
  • 1,812
  • 12
  • 8
  • Thank you very much for your help. I've my openStack Dashboard located on: /srv/www/openstack-dashboard/* so, if I correctly understand your explanation and everything I read on the internet regarding PYTHONPATH, my export should look like this: export $PYTHONPATH='/srv/www/' isn't it? If it's right, I'm still facing the same problem with the same message after having correct my path and stop/start my uWSGI server. It seems that python is not using my pythonpath or I'm misconfiguring my path. – Dr I Apr 08 '13 at 12:04
  • 1
    honestly i do not know openstack, but if you want to be sure to add a directory to the pythonpath just add --pythonpath /srv/www to the uwsgi options (you can specify it multiple times to add more directories) – roberto Apr 08 '13 at 12:18