010110110101 010110110101 - 1 year ago 541
Python Question

uwsgi + Flask + virtualenv ImportError: no module named site

(Other posts on SO are similar, but none have the specific combination of uwsgi + Flask + virtualenv) (This one is closest)

I installed uwsgi via apt-get. I also tried pip install wsgi. Both gave me the same issue.

Test command:

sudo uwsgi -s /tmp/uwsgi.sock -w myapp:app -H myvirtualenv


Python version: 2.7.4 (default, Apr 19, 2013, 18:35:44) [GCC 4.7.3]
Set PythonHome to myvirtualenv
ImportError: No module named site

I can otherwise run my app in the virtual env.

Answer Source

See the answer from @JRajan first.

If you're sure you just want to suppress the error, mouseover below.

Add --no-site to your command or no-site=true to your uwsgi.ini file.