Joliet
Joliet

Reputation: 101

No module named 'django' uWSGI

in a nutshell I am getting the following error message from uWSGI when I try to test my installation against the examples found here:

 $ uwsgi --socket 127.0.0.1:3031 --chdir /home/user/~Env/proj0/proj0 --wsgi-file wsgi.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191
 *** Starting uWSGI 2.0.15 (64bit) on [Wed May 31 14:10:35 2017] ***
 compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-11) on 30 May 2017 20:50:53
 os: Linux-3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017
 nodename: echo.com
 machine: x86_64
 clock source: unix
 pcre jit disabled
 detected number of CPU cores: 2
 current working directory: /home/user/~Env
 detected binary path: /usr/local/bin/uwsgi
 chdir() to /home/user/~Env/proj0/proj0
 your processes number limit is 4096
 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 TCP address 127.0.0.1:3031 fd 3
 Python version: 3.6.1 (default, May 29 2017, 14:21:37)  [GCC 4.8.5 20150623 
 (Red Hat 4.8.5-11)]
 Python main interpreter initialized at 0x1639580
 python threads support enabled
 your server socket listen backlog is limited to 100 connections
 your mercy for graceful operations on workers is 60 seconds
 mapped 415360 bytes (405 KB) for 8 cores
 *** Operational MODE: preforking+threaded ***
 Traceback (most recent call last):
 File "wsgi.py", line 12, in <module>
    from django.core.wsgi import get_wsgi_application
 ModuleNotFoundError: No module named 'django'
 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 master process (pid: 20065)
 spawned uWSGI worker 1 (pid: 20066, cores: 2)
 spawned uWSGI worker 2 (pid: 20067, cores: 2)
 spawned uWSGI worker 3 (pid: 20068, cores: 2)
 spawned uWSGI worker 4 (pid: 20069, cores: 2)
 *** Stats server enabled on 127.0.0.1:9191 fd: 15 ***

So obviously it found my wsgi.py file, but not Django. I'm not sure if I screwed up installing uWSGI system wide, my virtualenv folder layout, or whatever. I had wanted to deploy my app soon, but this takes precedence since I want to use nginx and uWSGI. My directory structure:

~Env---
     projectenv    proj0
          bin           proj0
          include            __init__.py
          libs               __pycache__
          .                  settings.py
                             urls.py
                             views.py
                             wsgi.py

Any help at this point would be great. Thanks.

Upvotes: 0

Views: 6117

Answers (1)

Ivan
Ivan

Reputation: 1507

It doesn't look like it's using a Python interpreter that has Django installed, so it's probably not seeing your virtualenv.

Did you take the appropriate step to add your virtualenv to uwsgi options?

https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#virtualenvs

Upvotes: 1

Related Questions