django, pyenv, uwsgi - ModuleNotFoundError: No module named 'django'

look at this at gsd.ini:

virtualenv = /home/toogy/.pyenv/versions/%n

have you install django under this virtualenv?


The problem was that the system-wide python version linked to uwsgi needs to be the same as the one of the virtualenv, which, I think, is a very stupid thing.

EDIT April 2021: I now recommend using gunicorn, which does not have this problem


In my case it was using the system wide uwsgi, I'm working using a virtualenv so if I execute

$ which uwsgi

I got /usr/local/python3.6/bin/uwsgi

As Valentin Iovene suggests you need to use the uwsgi from your virtual environment

My directories structure is something like this:

~/Env
--/app
--/bin
----/....
----/uwsgi <-- This should be the good one
----/...
--/include
--/lib

(The app directory is where my django app resides)

In my case uwsgi file hasn't execution permissions so I only executed:

$ chmod +x ~/Env/bin/uwsgi

Finally under my app directory I executed the uwsgi command as follows:

../bin/uwsgi --http :8000 --module app.wsgi

Now I can see my app working now :)

I'm following this guide: https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

Next steps are configuring nginx and https...

I know it's a late response but hope this helps and shared what worked for me.