Nginx & uWSGI: ImportError: No module named site

djangonginxuwsgi

I'm receiving an error: ImportError: No module named site according to my uWSGI log.

test_proj.ini:

[uwsgi]
chdir = /home/%n/app
module = %n.wsgi
home = /home/%n/app/venv
master = true
processes = 10
chmod-socket = 664
socket = /home/%n/uwsgi/socket
daemonize = /home/%n/uwsgi/log
pidfile = /home/%n/uwsgi/pid

nginx:

server {
        listen 8888;
        server_name 192.168.88.187;

        # Set up django static file serving
        location /static {
                alias /home/test_proj/app/static/;
        }

        # pass all non-static request to uWSGI
        location / {
                uwsgi_pass unix:///home/test_proj/uwsgi/socket;
                include uwsgi_params;
        }
}

pip freeze:

Django==1.7.1
django-braces==1.4.0
django-cors-headers==0.13
django-dynamic-settings==1.1.0
django-oauth-toolkit==0.7.2
django-uuidfield==0.5.0
djangorestframework==3.0.0
oauthlib==0.7.2
psycopg2==2.5.4
six==1.8.0

I also have uWSGI installed globally. Am I missing something in the ini file or is it because of my nginx settings? I've tried different combinations of the ini file.

I've also tried adding no-site = true inside the ini but I learned that it shouldn't be added to the ini file even though it removes the error and produces a different error.

I also followed this tutorial but still no luck.

Thanks.

Best Answer

The reason why it wasn't working is because I installed uwsgi using the regular pip command. Since I have both Python 2 & 3 in the machine, I need to install uwsgi using pip3.

The command I ran: pip3 install uwsgi

Related Topic