M
M
MazaFakagro2012-06-29 16:47:43
Django
MazaFakagro, 2012-06-29 16:47:43

"ImportError: No module named site" error ( Django+uwsgi+nginx) how to fix?

I'm trying to run a clean Django project in conjunction with nginx + uwsgi (ubuntu 12.10)
The project is in the / home / example folder
after starting nginx and uwsgi will fall out with an error in the uwsgi logs
ImportError: No module named site
nginx config

server {<br><br>
  # Make site accessible from http://localhost/<br>
  server_name example.com;<br><br>
    location /static {<br>
        alias /home/example/static/example;<br>
    }<br><br>
    location / {<br>
        uwsgi_pass unix:///run/uwsgi/app/example/socket;<br>
        include uwsgi_params;<br>
    }<br><br>

example.ini config for uwsgi
[uwsgi]<br><br>
plugins = python27<br>
virtualenv = /home/example/<br>
env = DJANGO_SETTINGS_MODULE=example.settings<br>
module = django.core.handlers.wsgi:WSGIHandler()<br>
chdir = /home/example/<br>
socket = /run/uwsgi/app/example/socket<br>
logto = /var/log/uwsgi/example.log<br>

what are the ideas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Avanov, 2012-06-29
@Ghostwriter

The correct solution is python setup.py develop
The second option is to mess around with the dynamic sys.path setting, but that's bad.

F
FeNUMe, 2012-06-30
@FeNUMe

location / { uwsgi_pass unix:///home/www/run/mysite/socket; include uwsgi_params; uwsgi_buffers 8 256k; }
uwsgi.yaml
uwsgi: socket: /home/www/run/mysite/socket pidfile: /home/www/run/mysite/pid pythonpath: /home/www/mysite env: DJANGO_SETTINGS_MODULE=mysite.settings module: mysite.wsgi daemonize: /home/www/mysite/logs/uwsgi.log max-requests: 5000 buffer-size: 32768 harakiri: 30 reload-mercy: 8 master: 1 no-orphans: 1 touch-reload: /home/www/mysite/conf/uwsgireload uid: www-data gid: www-data chmod-socket: 660
wsgi.py is the standard one that creates djanga 1.4 and the project structure itself from the new djanga.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question