I'm attempting to run a series of Python apps from supervisor. It works fine on Mac OSX, but when I attempt to run the same app on Ubuntu, supervisor doesn't seem to be activating the virtualenv so my scripts are throwing errors.

Here is my structure:

- app.py
- venv
- supervisor.conf

My supervisor.conf file looks like this:

autorestart = false
autostart = false
startsecs = 0
command = python app.py
startretries = 1

file = /tmp/supervisor.sock

logfile = logs/supervisord.log
pidfile = logs/supervisord.pid

serverurl = unix:///tmp/supervisor.sock

supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

username = supervisor_admin
password = 

username = supervisor_admin
password = 
port = *:9001

How can I get supervisor to run the python app inside of the virtual enviroment?


The command you provide should use the python binary inside the virtual environment:

command = /home/user/Sites/my-site/venv/bin/python /home/user/Sites/my-site/app.py
  • what about packages installed in that virtualenv? will the python detect them automatically? – Prasanth Feb 23 '15 at 20:07
  • 2
    Yes, calling the right Python binary will setup the paths correctly to use packages installed in the virtualenv. – mgorven Feb 23 '15 at 20:11
  • 3
    Are you sure about that @mgorven? It's not doing that for me – skolsuper Jan 11 '16 at 4:35
  • 1
    what about other configurations of virtualenv like postactivate, enviroment vairables? wouldn't it be better to run a command that first activates the virtualenv and then executes the python script? – MikeL Apr 30 '17 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.