No module named flask while running uWSGI
Question: I have a very simple flask app (myflaskapp.py):

    
    
    from flask import Flask
    
    app = Flask(__name__)
    
    @app.route('/')
    def index():
        return "<span style='color:red'>I am app 1</span>"
    

If I run:

    
    
    uwsgi --http-socket :3031 --plugin python --wsgi-file myflaskapp.py --callable app
    

I get the following output:

    
    
    Traceback (most recent call last):
      File "myflaskapp.py", line 1, in <module>
        from flask import Flask
    ImportError: No module named flask
    unable to load app 0 (mountpoint='') (callable not found or import error)
    *** no app loaded. going in full dynamic mode ***
    

and I don't understand why. I have flask installed (pip install flask). If I
run ipython and import flask it also works there. Any ideas? Thanks!


Answer: In the end what worked for me was adding -H /path/to/virtualenv to the uWSGI
command:

    
    
    uwsgi --http-socket :3031 --plugin python --wsgi-file myflaskapp.py --callable app -H /path/to/virtualenv
    

I also had different Python versions in the virtualenv and for uWSGI. I'm
still investigating if this could cause any problems.

