title: Create and activate Conda environment in same script
body: <p>I'm trying to write an installer that uses both <code>conda</code> and <code>pip</code>. I'd like to activate the <code>conda</code> environment to call <code>pip</code>, but doing this in the same script causes problems.</p>
  
  <pre><code>#!/usr/bin/env bash
  set -euo pipefail
  
  conda create -y --name myenv python=3.6
  conda init bash
  conda activate myenv
  # Perform pip-based installation here.
  </code></pre>
  
  <p>Running <code>bash setup-environment.sh</code> fails at the <code>conda activate</code> step:</p>
  
  <pre><code>CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
  To initialize your shell, run
  
      $ conda init &lt;SHELL_NAME&gt;
  
  Currently supported shells are:
    - bash
    - fish
    - tcsh
    - xonsh
    - zsh
    - powershell
  
  See 'conda init --help' for more information and options.
  
  IMPORTANT: You may need to close and restart your shell after running 'conda init'.
  </code></pre>
  
  <p>While it's helpful to know that restarting my shell will solve the problem, I can't do that within the script. Is there a workaround?</p>