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.

koralarts
  • 261
  • 1
  • 3
  • 11
  • 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 09:18

3 Answers3

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

koralarts
  • 261
  • 1
  • 3
  • 11
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.

Cody Django
  • 133
  • 6
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.

Marco
  • 1,679
  • 3
  • 17
  • 31
noPE
  • 111
  • 3