import flask on wsgi virtual host fails
Question: Having the following directory structure and setup:

    
    
    .
    ├── app
    │   ├── __init__.py
    │   ├── __init__.pyc
    │   ├── static
    │   ├── templates
    │   │   ├── base.html
    │   │   └── index.html
    │   ├── views.py
    │   └── views.pyc
    ├── flask
    ├── myapp.wsgi
    ├── run.py
    ├── run.pyc
    └── tmp
    

**myapp.wsgi**

    
    
    #!/usr/bin/python
    import sys, os, logging
    logging.basicConfig(stream=sys.stderr)
    #sys.path.insert(0,"/var/www/otherStuff/myApp/")
    sys.path.insert(0, os.path.dirname(__file__))
    
    #from app import app
    from app import app as application
    application.secret_key = 'xyz'
    
    if __name__ == '__main__':
        app.run(host='0.0.0.0',debug=True)
    

**__init__.py**

    
    
    from flask import Flask
    
    app = Flask(__name__)
    from app import views
    

**vhost.conf**

    
    
    <VirtualHost *:80>
            ServerName local.myapp.com
            WSGIScriptAlias / /var/www/otherStuff/myApp/myappwsgi
            <Directory /var/www/otherStuff/myApp/app>
                    Order allow,deny
                    Allow from all
            </Directory>
            #Alias /static /var/www/otherStuff/myApp/static
            #<Directory /var/www/otherStuff/myApp/static>
            #       Order allow,deny
            #       Allow from all
            #</Directory>
            ErrorLog /var/www/logs/myApp-error.log
            LogLevel warn
            CustomLog /var/www/logs/myApp-access.log combined
    </VirtualHost>
    

I can't seem to figure out, why the `Flask` dependency is not loaded and
therefore, it fails to run

    
    
    mod_wsgi (pid=19668): Target WSGI script '/var/www/otherStuff/myApp/myapp.wsgi' cannot be loaded as Python module., referer: http://local.myapp.com/
    mod_wsgi (pid=19668): Exception occurred processing WSGI script '/var/www/otherStuff/myApp/myapp.wsgi'., referer: http://local.myapp.com/
    Traceback (most recent call last):, referer: http://local.myapp.com/
      File "/var/www/otherStuff/myApp/myapp.wsgi", line 8, in <module>, referer: http://local.myapp.com/
        from app import app as application, referer: http://local.myapp.com/
      File "/var/www/otherStuff/myApp/app/__init__.py", line 1, in <module>, referer: http://local.myapp.com/
        from flask import Flask, referer: http://local.myapp.com/
    ImportError: No module named flask, referer: http://local.myapp.com/
    

**UPDATE**

`flask` is the virtualenv:

    
    
    flask/
    ├── bin
    ├── include
    ├── lib
    ├── lib64 -> /home/alexb/www/otherStuff/faqColab/flask/lib
    ├── local
    └── pyvenv.cfg
    


Answer: You need to tell mod_wsgi how to find packages in your virtual environment.
I'm not positive I have your folder structure exactly correct, but it should
be something like this.

    
    
    WSGIPythonPath /var/www/otherStuff/myApp:/var/www/otherStuff/myApp/flask/lib/python2.7/site-packages
    

