Django uwsgi import error
Question: I have a Django project with one app called `subscribe`. In root `urls.py` I
use include from `subscribe`'s `urls.py`.

I put to `INSTALLED_APPS` `subscribe` and in `subscribe`'s `urls.py` I use
`subscribe.views.<name>` for call my views. When server run as `python
manage.py runserver` locally all works fine. But when server run on
nginx+uwsgi with virtualenv, I've got `ImportError: No module named
subscribe`. When I changing `subscribe` to `project.subscribe` in
`INSTALLED_APPS` and in `subscribe`'s `urls.py` changing
`subscribe.views.<name>` to `project.subscribe.views.<name>` all works fine.

uwsgi config:

    
    
    [uwsgi] 
    socket = 127.0.0.1:9003 
    workers = 2 
    master = true 
    virtualenv = /home/user/python 
    chdir = /home/user 
    env = DJANGO_SETTINGS_MODULE=project.settings 
    module = django.core.handlers.wsgi:WSGIHandler()
    daemonize = /home/user/uwsgi.log
    

Why should I use absolute path import and how I can change it to relative back
on nginx+uwsgi with virtualenv?


Answer: Your uwsgi config should include `pythonpath=/path/where/lives/settings.py/`
directive, so python interpreter will know where to find your apps.

Find more information about uwsgi config options:

  * <http://projects.unbit.it/uwsgi/wiki/Doc>
  * <http://projects.unbit.it/uwsgi/wiki/Example>

