Working with environments (AEN 4.2.0)
=====================================

.. raw:: html

    <p>AEN runs on conda, a package management system and environment
    management system for installing multiple versions of software packages and
    their dependencies and switching easily between them.</p>
    <p>A conda environment usually includes 1 version of Python or R language and some
    packages.</p>
    <p>The ability to have a custom project environment is one of the most powerful
    features of AEN. Your project environment is integrated so that all of your
    project applications recognize it and all of your team members have access to
    it.</p>
    <p>This section contains information about:</p>
    <ul class="simple">
    <li><a class="reference internal" href="#create-default-env-jn"><span class="std std-ref">Creating a default conda environment using the Jupyter Notebook application</span></a></li>
    <li><a class="reference internal" href="#create-default-env"><span class="std std-ref">Creating a default conda environment using the Jupyter Notebook application</span></a></li>
    <li><a class="reference internal" href="#using-env"><span class="std std-ref">Using your conda environment in a notebook</span></a></li>
    <li><a class="reference internal" href="#custom-env"><span class="std std-ref">Customizing your conda environment</span></a></li>
    <li><a class="reference internal" href="#install-conda-terminal"><span class="std std-ref">Installing a conda package using Terminal</span></a></li>
    <li><a class="reference internal" href="#install-conda-nb"><span class="std std-ref">Installing a conda package using Notebook</span></a></li>
    <li><a class="reference internal" href="#uninstall-conda"><span class="std std-ref">Uninstalling a conda package</span></a></li>
    </ul>
    <p>NOTE: This conda environments guide is specific to AEN. For full conda
    documentation&#8212;including cheat sheets, a conda test drive, and command
    reference&#8212;see the <a class="reference external" href="http://conda.pydata.org/docs/">conda documentation</a>.</p>
    <div class="section" id="creating-a-default-conda-environment-using-the-jupyter-notebook-application">
    <span id="create-default-env-jn"></span><span id="create-default-env"></span><h2>Creating a default conda environment using the Jupyter Notebook application<a class="headerlink" href="#creating-a-default-conda-environment-using-the-jupyter-notebook-application" title="Permalink to this headline">¶</a></h2>
    <p>You can create, activate, and install packages and deactivate environments from
    within the Notebook menu bar.</p>
    <p>To install from the Notebook menu bar:</p>
    <ol class="arabic simple">
    <li>Click the <strong>Conda</strong> tab and select the plus sign icon.</li>
    <li>Search for <code class="docutils literal"><span class="pre">numpy</span></code> in the package search box.</li>
    <li>Select numpy from the search results.</li>
    </ol>
    <blockquote>
    <div><blockquote>
    <div><div class="figure">
    <a class="reference internal image-reference" href="../../../../_images/ae-notebooks/4.2.0/aen-env-numpy.png"><img alt="../../../../_images/ae-notebooks/4.2.0/aen-env-numpy.png" src="../../../../_images/ae-notebooks/4.2.0/aen-env-numpy.png" style="width: 50%;" /></a>
    </div>
    </div></blockquote>
    <div class="line-block">
    <div class="line"><br /></div>
    </div>
    </div></blockquote>
    <ol class="arabic simple">
    <li>Click the Install button.</li>
    </ol>
    <p>The environment is added to the project&#8217;s <code class="docutils literal"><span class="pre">env</span></code> directory.</p>
    </div>
    <div class="section" id="creating-a-default-conda-environment-using-terminal">
    <h2>Creating a default conda environment using Terminal<a class="headerlink" href="#creating-a-default-conda-environment-using-terminal" title="Permalink to this headline">¶</a></h2>
    <p>In AEN, all new environments created with conda automatically include Python,
    Jupyter Notebooks and pip. You can specify any other packages you want included
    in your new environment.</p>
    <p>TIP: By default, conda creates a new environment in your project&#8217;s <code class="docutils literal"><span class="pre">env</span></code>
    directory&#8212;so that all team members have access to the environment. For
    information about limiting your team member&#8217;s read, write or execute
    permissions, see <a class="reference internal" href="../basic-tasks/apps/use-workbench.html"><span class="doc">Workbench</span></a>.</p>
    <p>To create a new environment within your AEN account, run the command
    <code class="docutils literal"><span class="pre">conda</span></code> in a <a class="reference internal" href="../basic-tasks/apps/use-terminal.html"><span class="doc">Terminal</span></a> application.</p>
    <p>EXAMPLE: To create a new environment named <code class="docutils literal"><span class="pre">WeatherModel</span></code> that contains
    Python, NumPy, pip and Jupyter Notebooks in your project&#8217;s <code class="docutils literal"><span class="pre">env</span></code> directory:</p>
    <ol class="arabic">
    <li><p class="first">Log in to AEN.</p>
    </li>
    <li><p class="first">Open a project.</p>
    </li>
    <li><p class="first">On the project home page, click the Terminal application icon
    to open a Terminal.</p>
    </li>
    <li><p class="first">Create the environment:</p>
    <div class="highlight-bash"><div class="highlight"><pre><span></span>conda create -n WeatherModel numpy
    </pre></div>
    </div>
    <p>TIP: Python, pip and Jupyter Notebooks are automatically installed in each
    new environment. You only need to specify NumPy in this command.</p>
    </li>
    <li><p class="first">Make the new environment your default:</p>
    <div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nb">source</span> activate WeatherModel
    </pre></div>
    </div>
    </li>
    <li><p class="first">To use your new environment with Jupyter Notebooks, open the Notebook application.</p>
    </li>
    <li><p class="first">Click the New button to open a new notebook. In the drop-down menu under Notebooks, the environment you just created is displayed.</p>
    </li>
    <li><p class="first">To activate that environment, select it.</p>
    <p>The environment is added to the project&#8217;s <code class="docutils literal"><span class="pre">env</span></code> directory.</p>
    <div class="figure">
    <a class="reference internal image-reference" href="../../../../_images/ae-notebooks/4.2.0/aen-env-weathermodel.png"><img alt="../../../../_images/ae-notebooks/4.2.0/aen-env-weathermodel.png" src="../../../../_images/ae-notebooks/4.2.0/aen-env-weathermodel.png" style="width: 50%;" /></a>
    </div>
    <div class="line-block">
    <div class="line"><br /></div>
    </div>
    </li>
    </ol>
    <p>NOTE: You can deactivate the new environment when you are finished with your
    notebook by opening the Terminal application and running the command
    <code class="docutils literal"><span class="pre">source</span> <span class="pre">deactivate</span></code>.</p>
    </div>
    <div class="section" id="using-your-conda-environment-in-a-notebook">
    <span id="using-env"></span><h2>Using your conda environment in a notebook<a class="headerlink" href="#using-your-conda-environment-in-a-notebook" title="Permalink to this headline">¶</a></h2>
    <p>Whether you have created an environment using conda in a terminal, or from
    the <strong>Conda</strong> tab in a notebook, you can use the conda environment in the same
    way.</p>
    <p>When working in a notebook, to select the environment you have created and want
    to use with that notebook, in the <strong>Kernel</strong> menu, select Change Kernel.</p>
    <p>EXAMPLE: If you have an environment named <code class="docutils literal"><span class="pre">my_env</span></code> in a project named
    <code class="docutils literal"><span class="pre">test1</span></code> that includes NumPy and SciPy and you want to use that environment
    in your notebook, in the <strong>Kernel</strong> menu, select Python [conda env:test1-my_env].</p>
    <p>The notebook code will run in that environment and can import NumPy and SciPy
    functions.</p>
    </div>
    <div class="section" id="customizing-your-conda-environment">
    <span id="custom-env"></span><h2>Customizing your conda environment<a class="headerlink" href="#customizing-your-conda-environment" title="Permalink to this headline">¶</a></h2>
    <p>If you need a Python package that AEN doesn&#8217;t include by default, you can
    install additional packages into your AEN environment.</p>
    <p>TIP: You cannot install packages into the default Anaconda environment. You must
    create your own environment before installing a new package into that environment.</p>
    <p>AEN is built on Anaconda, so you can install additional Python packages using
    conda or pip&#8212;both of which are included with Anaconda.</p>
    </div>
    <div class="section" id="installing-a-conda-package-using-terminal">
    <span id="install-conda-terminal"></span><h2>Installing a conda package using Terminal<a class="headerlink" href="#installing-a-conda-package-using-terminal" title="Permalink to this headline">¶</a></h2>
    <p>To install a conda package using the Terminal application:</p>
    <ol class="arabic">
    <li><p class="first">Create and activate the environment using the steps in <a class="reference internal" href="#create-default-env"><span class="std std-ref">Creating a default conda environment using the Jupyter Notebook application</span></a>.</p>
    </li>
    <li><p class="first">In your Terminal application, run the command <code class="docutils literal"><span class="pre">conda</span> <span class="pre">install</span> <span class="pre">&lt;packagename&gt;</span></code>.</p>
    <p>NOTE: Be sure to specify the Python version you want when using conda to
    create the environment, or it will use the same version as root.</p>
    <p>EXAMPLE:</p>
    <div class="highlight-bash"><div class="highlight"><pre><span></span>conda create -n mypy3 <span class="nv">python</span><span class="o">=</span><span class="m">3</span> numpy scipy
    </pre></div>
    </div>
    <p>A conda environment named mypy3, running on Python 3 and containing NumPy
    and SciPy is created. All subsequent packages added to this environment will
    be the Python 3 compatible versions.</p>
    </li>
    </ol>
    </div>
    <div class="section" id="installing-a-conda-package-using-notebook">
    <span id="install-conda-nb"></span><h2>Installing a conda package using Notebook<a class="headerlink" href="#installing-a-conda-package-using-notebook" title="Permalink to this headline">¶</a></h2>
    <p>You can also install the package within your notebook without using the terminal
    app:</p>
    <ol class="arabic simple">
    <li>From the Notebook application, click the <strong>Conda</strong> tab.</li>
    <li>Select the environment you wish to use.</li>
    <li>Search for the package you want to add.</li>
    <li>Click the Install button.</li>
    </ol>
    </div>
    <div class="section" id="uninstalling-a-conda-package">
    <span id="uninstall-conda"></span><h2>Uninstalling a conda package<a class="headerlink" href="#uninstalling-a-conda-package" title="Permalink to this headline">¶</a></h2>
    <p>To uninstall a package using this method, run the command <code class="docutils literal"><span class="pre">conda</span> <span class="pre">remove</span> <span class="pre">&lt;packagename&gt;</span></code>.</p>
    <p>NOTE: Replace <code class="docutils literal"><span class="pre">&lt;packagename&gt;</span></code> with the name of the package you are
    uninstalling.</p>
    </div>
