0
votes

I am trying to deploy a flask app using boto3 and aws3 buckets, on an ububtu18.04 server. Using apache2 and mod_wsgi.

The app runs smoothly when I run it locally or test it on server trough port 4447, by pipenv run python3 app.py. However when it try to deploy it trough apache with mod_wsgi with the same virtualenv I am getting, No module named concurrent.futures I have installed futures, pipenv install futures

but it doesn’t work!

[Sat Jun 06 08:34:41.524049 2020] [wsgi:error] [pid 4927:tid 140619001349888] [client 92.251.60.228:56124] s3_resource = boto3.resource('s3') …………………………………………………………………………………………………………………… import concurrent.futures

[Sat Jun 06 08:34:41.526797 2020] [wsgi:error] [pid 4927:tid 140619001349888] [client 92.251.60.228:56124] ImportError: No module named concurrent.futures

.config file:

    WSGIScriptAlias /trendy /var/www/trendy/flaskapp.wsgi
    <Directory /var/www/trendy>
        Order allow,deny
        Allow from all
    </Directory>
    Alias /static /var/www/trendy/static
    <Directory /var/www/trendy/static/>
        Order allow,deny
        Allow from all
    </Directory>

flaskapp.wsgi file:

#!/usr/bin/python3.8
activate_this = '/home/ubuntu/.local/share/virtualenvs/trendy-TkTqI5qg/bin/activate_this.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))
import sys
import logging
from uuid import uuid4
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/trendy/")

from app import app as application
application.secret_key = uuid4().hex
1

1 Answers

0
votes

Append project path and make sure you create environment in project:

#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/webApp/")
sys.path.append("/var/www/webApp/webApp") # appending project path

from webApp import app as application
application.secret_key = uuid4().hex