6

I am trying to run my sample django application using uWSGI and nginx. But I am getting import error, no module named py. I am not sure where should I add the python path.

I am running with the following command.

sudo uwsgi --socket mysite.socket --module wsgi.py --chmod-socket=666. 

I even tried passing path in the parameter --pythonpath, still the same error.

This is how my wsgi.py looks like

enter code here

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

When I try running, I get the following messages

ubuntu@ubuntu1204desktopi386:/usr/local/lib/python2.7/site-packages/mysite/mysite
$ sudo uwsgi --socket mysite.socket --module wsgi.py --chmod-socket=666 
*** Starting uWSGI 1.9.18.1 (32bit) on [Mon Oct 14 13:15:19 2013] ***
compiled with version: 4.6.3 on 13 October 2013 02:53:51
os: Linux-3.5.0-23-generic #35~precise1-Ubuntu SMP Fri Jan 25 17:15:33 UTC 2013
nodename: ubuntu1204desktopi386
machine: i686
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /usr/local/lib/python2.7/site-packages/mysite/mysite
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3846
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address mysite.socket fd 3
Python version: 2.7.3 (default, Sep 26 2013, 20:26:19)  [GCC 4.6.3]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x9644d68
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 64024 bytes (62 KB) for 1 cores
*** Operational MODE: single process ***
ImportError: No module named py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 2311, cores: 1)
2
  • In any of your files have you done something like import something.py ? Commented Oct 14, 2013 at 20:23
  • No. It was because I was passing a python file for --module wsgi.py. It should be just a module, --module wsgi. Commented Oct 14, 2013 at 20:30

3 Answers 3

9

The --module argument is presumably meant to be a Python module, not a file. So you probably just need --module=wsgi.

Sign up to request clarification or add additional context in comments.

Comments

4

i guess you can also use , --wsgi-file wsgi.py like this

 $ uwsgi --socket 127.0.0.1:8000 --wsgi-file my_proj/wsgi.py

Make sure you run command from same folder

Comments

2

If python manage.py runserver 0.0.0.0:8024 can work well, then

This also can work(run it on the same directory as above command):

uwsgi --http :8024 --module mysite.wsgi

mysite is the name of this django project

uwsgi version is 2.0.14; django version is 1.10.

ref: https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.