albertoivo
albertoivo

Reputation: 409

Error trying to run mod_wsgi on a apache server

I have a Flask Project structure directory inside /var/www:

item-catalog-fullstacknd\
    itemCatalogApp.wsgi
    itemCatalogApp\
        __init__.py

This is th WSGI file above:

import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/item-catalog-fullstacknd/")
from itemCatalogApp import app as application
application.secret_key = 'Add your secret key' 

This is the /etc/apache2/sites-enabled/000-default.conf

WSGIPythonPath /var/www/item-catalog-fullstacknd/itemCatalogApp/
<VirtualHost *:80>
    WSGIScriptAlias / /var/www/item-catalog-fullstacknd/itemCatalogApp.wsgi

            <Directory /var/www/item-catalog-fullstacknd/itemCatalogApp>
                    Order allow,deny
                    Allow from all
            </Directory>

            Alias /static /var/www/item-catalog-fullstacknd/itemCatalogApp/static

            <Directory /var/www/item-catalog-fullstacknd/itemCatalogApp/static/>
                    Order allow,deny
                    Allow from all
            </Directory>

</VirtualHost>

And I am getting the following error:

mod_wsgi (pid=17586): Exception occurred processing WSGI script '/var/www/item-catalog-fullstacknd/itemCatalogApp.wsgi'.
 Traceback (most recent call last):
   File "/var/www/item-catalog-fullstacknd/itemCatalogApp.wsgi", line 6, in <module>
     from itemCatalogApp import app as application
   File "/var/www/item-catalog-fullstacknd/itemCatalogApp/__init__.py", line 3, in <module>
     from flask import Flask, jsonify, render_template, request
 ImportError: No module named flask

I already pip install all the modules contained in the requirements.txt file. I have no idea what to do anymore.

Upvotes: 0

Views: 49

Answers (1)

Fine
Fine

Reputation: 2154

It's possible that you've installed modules for a different python executable, not the one that your mod_wsgi uses by default. To check that, add to the beggining of your WSGI file:

import sys
print(sys.executable)

Then, open shell, run a python and type the same code there. If path is different, you should specify WSGIPythonHome to point at the desired python executable.

Upvotes: 1

Related Questions