How do I run uwsgi with virtualenv

To use the activated virtualenv you can use this config snippet in your uwsgi.ini:

; If VIRTUAL_ENV is set then use its value to specify the virtualenv directory
if-env = VIRTUAL_ENV
virtualenv = %(_)
endif =

As user995394 pointed out, there is a way to tell uWSGI use existing virtual environment. However, when I pass uWSGI option in form virtualenv = /full/path/to/my/virtualenv (it's from INI config) it complains about ImportError: No module named site. The workaround I found is that you launch uWSGI from folder where your virtualenv is and pass just virtualenv = my_virtualenv_name (i.e. path is relative).

I use uWSGI 2.0.


Others' answers didn't help, and I added path to virtualenv to uwsgi.ini configuration file. The error disappeared.

pythonpath = /path-to-virtualenv/project/lib/python2.7/site-packages

Use -H to set virtualenv to python path.

uwsgi -H /path/to/your/virtualenv 

http://uwsgi-docs.readthedocs.org/en/latest/Options.html#virtualenv