I'm trying to run a Flask app using a conda env with uwsgi and supervisor.
I managed to solve a first issue regarding the path of the wsgi script, but I cannot find how to set the conda env.
My uwsgi config file /home/me/Development/flask/myflaskapp/myflaskapp.ini
is
[uwsgi]
module = wsgi
master = true
process = 2
chmod-socket = 666
chdir = /home/me/Development/flask/myflaskapp
socket = /home/me/Development/flask/myflaskapp/run/myflaskapp.sock
callable = app
vacuum = true
and my supervisor config is
[program:uwsgi-myflaskapp]
command=/home/me/Development/miniconda/envs/myflaskapp/bin/uwsgi /home/me/Development/flask/myflaskapp/myflaskapp.ini
autostart=true
autorestart=true
stdout_logfile=/home/me/Development/flask/myflaskapp/log/uwsgi-myflaskapp.log
redirect_stderr=true
exitcodes=0
When I start uwsgi through supervisor I get
*** Operational MODE: single process ***
Traceback (most recent call last):
File "./wsgi.py", line 1, in <module>
from myflaskapp import app
File "./myflaskapp/__init__.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
So I guess I the conda env is not set. How can I set it?
I had to set PATH in my supervisor config file
environment=PATH=/home/me/Development/miniconda/envs/myflaskapp/bin
You use the -H tag when starting uwsgi from the command line to set the Python path
http://uwsgi-docs.readthedocs.org/en/latest/Options.html#virtualenv
So in your case, in the supervisor config, change your command to:
command=/home/me/Development/miniconda/envs/myflaskapp/bin/uwsgi -H /path/to/your/virtualenv /home/me/Development/flask/myflaskapp/myflaskapp.ini
You can find your virtualenv path with
which python
On the command line with your virtualenv activated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With