title: mod_wsgi with Flask app: ImportError: No module named flask
body: <p>In CentOS 6.4, I created python virtual environment in /var/www/html/venv folder. Then after activating the virtual environment, I installed all necessary python libraries for my flask application. I checked, that Flask libraries were in /var/www/html/venv/lib/python2.7/site-packages folder. I've already installed and loaded mod_wsgi. Now in my flask app, which is in /var/www/html/truckman/wsgi folder, I created truckman.wsgi file with the following content:</p>
  
  <pre><code>activate_this = '/var/www/html/venv/bin/activate_this.py'
  execfile(activate_this, dict(__file__=activate_this))
  
  import sys
  sys.path.insert(0, '/var/www/html/truckman/wsgi/')
  
  from app import app as application
  import config
  application.config.from_object(config.Dev)
  </code></pre>
  
  <p>Also, in /etc/httpd/conf/httpd.conf I added:</p>
  
  <pre><code>&lt;VirtualHost *&gt;
      WSGIScriptAlias / /var/www/html/truckman/wsgi/truckman.wsgi
      &lt;Directory /var/www/html/truckman/wsgi&gt;
          Order deny,allow
          Allow from all
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Now, in /var/www/html/truckman/wsgi folder, I created run.py file with the following content:</p>
  
  <pre><code>from app import app as application
  import config
  application.config.from_object(config.Dev)
  if __name__ == "__main__":
      application.run(port=5001)
  </code></pre>
  
  <p>Now I tested my app with flask's development server; if I execute "python run.py", my app works as expected. I can browse to localhost:5001, and the app's initial page shows up. </p>
  
  <p>Then I tested my app with mod_wsgi: First killed run.py process, and restarted httpd service, and after that browsed to localhost; but it returned: "500 Internal Server Error". In /etc/httpd/logs/error_log file I found the following error message: "ImportError: No module named flask". What's wrong with my settings?</p>