5

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.

1
  • the HOME path is probably not correct. Try adding a '/' at the end. When you list that folder you should see bin/, include/, lib/, ...,mysite/ etc. – Alex Dec 25 '14 at 9:18
11

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

1

The reason why you're getting this error is because the modules (site, os, etc) couldn't be found in the virtual environment specified in the home directive. Using the right version of pip may have worked for you, but only because it fixes your virtualenv issue.

1

If you are on venv, then run uwsgi using the full path of uwsgi where it resides inside the venv like /usr/venv/bin/uwsgi. Default uwsgi might be residing somewhere else.

Try which uwsgi to locate it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.