Search code examples
pythonflaskvirtualenvuwsgi

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

Result:

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.


Solution

  • See the answer from @JRajan first.

    If you're sure you just want to suppress the error and not actually solve the underlying issue, you should add --no-site to your command or no-site=true to your uwsgi.ini file.