nginx + uwsgi + django “could not import settings”

Question!

Ok I must be so stupid but I cannot figure out how to get this working, I have nearly two hours and I cannot advance anymore and I honestly don't know what's wrong, I've read a lot of guides and I am doing everything fine..

But let's paste you the configs:

dir struct:

├── apps
├── config
    └── wsgi.py
    ├── settings.py
├── dev
├── env
├── static
│   ├── css
│   ├── img
│   └── js
│       └── vendor
└── templates
    ├── admin
    │   └── supervisor
    └── base
├── manage.py

wsgi.py

import os
import sys

from site import addsitedir
from os.path import abspath, dirname, join

sys.path.insert(0, abspath(join(dirname(__file__), "..")))
sys.path.insert(0, abspath(join(dirname(__file__), "../apps")))
sys.path.insert(1, abspath(join(dirname(__file__), "../config")))

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

backoffice.ini

[uwsgi]
chdir = /var/www/backoffice
mountpoint = /var/www/backoffice
gid = www-data
uid = www-data
socket = /tmp/uwsgi.backoffice.sock
virtualenv = /var/www/backoffice/env
plugins = python
master = True
chmod-socket = 666
memory-report = 1
harakiri = 20
processes = 4
profiler = 1
pythonpath = /var/www/backoffice
vacuum = True
max-requests = 5000

Then I run the following command:

uwsgi --ini /var/www/backoffice/backoffice.ini -b 32000 --wsgi-file /var/www/backoffice /config/wsgi.py

And I get the error of "could not import settings it is on sys.path" of course it is!!

sys.path

['/var/www/backoffice/', '.', '', '/var/www/backoffice/env/local/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg', '/var/www/backoffice/env/local/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg', '/var/www/backoffice/env/src/django-logicaldelete', '/var/www/backoffice/env/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg', '/var/www/backoffice/env/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg', '/var/www/backoffice/env/lib/python2.7', '/var/www/backoffice/env/lib/python2.7/plat-i386-linux-gnu', '/var/www/backoffice/env/lib/python2.7/lib-tk', '/var/www/backoffice/env/lib/python2.7/lib-old', '/var/www/backoffice/env/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-i386-linux-gnu', '/usr/lib/python2.7/lib-tk', '/var/www/backoffice/env/local/lib/python2.7/site-packages', '/var/www/backoffice/env/lib/python2.7/site-packages']

Any hint? what's too obvious that I'm not seeing.. Thanks



Answers

I checked again and @sk1p pointed out that I might be have issues on my settings which was true after debugging deep, I was importing the translation library and that made a circular import issue.

Thanks for the help man



This video can help you solving your question :)
By: admin