title: How to activate python virtual environment in supervisor?
body: <p><strong>What I want to do?</strong></p>
  
  <p>Activate tensorflow_p36 environment and run <code>python wsgi.py</code></p>
  
  <p><strong>What my <code>supervisord.conf</code> file looks like?</strong></p>
  
  <pre><code>[program:my_program]
  command = /home/ec2-user/anaconda3/envs/tensorflow_p36/bin/python /home/ec2-user/abc/wsgi.py
  directory= /home/ec2-user/abc/
  environment=PATH= "/home/ec2-user/anaconda3/envs/tensorflow_p36/bin"
  user= ec2-user
  redirect_stderr = True
  stdout_logfile = /home/ec2-user/abc/logs/gunicorn/gunicorn_stdout.log
  stderr_logfile = /home/ec2-user/abc/logs/gunicorn/gunicorn_stderr.log
  </code></pre>
  
  <p>The file is located in default /etc/supervisord.conf location.</p>
  
  <p><strong>What have I tried so far?</strong></p>
  
  <p>I tried all the solutions from <a href="https://stackoverflow.com/questions/15202760/how-to-use-virtualenvwrapper-in-supervisor">this question</a>, but the modules installed in that virtual environment are not getting imported. For example, I get errors in importing tensorflow, flask etc. Whereas, when I do the same command in terminal after <code>source activate tensorflow_p36</code> it works just fine. </p>
  
  <p>I also tried grouping multiple programs suggested in <a href="https://stackoverflow.com/a/28994845/2679662">this answer</a>, where I activated virtual environment in first program and ran python command in second program and grouped them together. Didn't work, was still getting the same import errors.</p>
  
  <p><strong>Extra info:</strong></p>
  
  <p>When I run <code>sudo service supervisord restart</code>, I get following message:</p>
  
  <p>Stopping supervisord:                                      [  OK  ]</p>
  
  <p>Starting supervisord: /usr/local/lib/python2.7/site-packages/supervisor-3.3.4-py2.7.egg/supervisor/options.py:461: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
    'Supervisord is running as root and it is searching '
                                                             [  OK  ]</p>