Anaconda Environments (AEN 4.0)
===============================

.. raw:: html

    <p>Anaconda Enterprise Notebooks runs on
    <a class="reference internal" href="../../anaconda/index.html"><span class="doc">Anaconda</span></a>. Anaconda
    supports multiple versions of Python and associated packages. An
    environment generally includes one version of Python or R language
    and some packages.</p>
    <p>The ability to have a custom environment for your project is one of the
    most powerful features of Anaconda Enterprise Notebooks.</p>
    <p>A project environment is integrated with the project so all project
    apps are aware of it and all project members have access to it.</p>
    <p>This is an introduction to conda environments specifically for AEN users.
    See <a class="reference external" href="http://conda.pydata.org/docs/">conda</a> for full documentation on
    using conda, as well as cheat sheets, a conda test drive, and command
    reference.</p>
    <div class="section" id="creating">
    <h2>Creating<a class="headerlink" href="#creating" title="Permalink to this headline">¶</a></h2>
    <p>Use the <code class="docutils literal"><span class="pre">conda</span></code> command in a terminal app to create new environments
    within your Anaconda
    Enterprise Notebooks account. In Anaconda Enterprise Notebooks, 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 the new environment in your project&#8217;s &#8220;env&#8221;
    directory so all team members have access to the new environment. You can
    limit their read, write and/or execute permission from the Workbench app,
    select the notebook name then from the drop-down menu that appears, select
    Permissions. See the <a class="reference internal" href="workbench.html"><span class="doc">Workbench</span></a> page for more information.</p>
    <p>EXAMPLE:</p>
    <p>Create a new environment named &#8220;WeatherModel&#8221; that contains
    Python, NumPy, pip and Jupyter Notebooks. This will be in your
    project&#8217;s &#8220;env&#8221; directory.</p>
    <p>Start by logging onto AEN and opening a project. This opens your
    project dashboard.</p>
    <p>Next, from your project&#8217;s dashboard, open the terminal application and
    enter the following:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">conda</span> <span class="n">create</span> <span class="o">-</span><span class="n">n</span> <span class="n">WeatherModel</span> <span class="n">numpy</span>
    </pre></div>
    </div>
    <p>Remember, Python, pip and Jupyter Notebooks are automatically installed in
    each new environment. This is why we need to specify only NumPy.</p>
    <p>To make this new environment your default environment, in your terminal app enter:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">source</span> <span class="n">activate</span> <span class="n">WeatherModel</span>
    </pre></div>
    </div>
    <p>When finished with your notebook, to deactivate this new environment,
    in your terminal app simply enter:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">source</span> <span class="n">deactivate</span>
    </pre></div>
    </div>
    <p>TIP: If you prefer to remain in the Notebook interface, you can create, activate,
    install packages and deactivate environments from within a notebook file menu by
    selecting the conda file tab and adding it with the &#8220;plus sign&#8221; icon. Then search
    for &#8220;numpy&#8221; in the package search box and click the Install button. Either way,
    the environment is located in the project&#8217;s same &#8220;env&#8221; directory.</p>
    </div>
    <div class="section" id="using-environments-in-notebooks">
    <h2>Using environments in notebooks<a class="headerlink" href="#using-environments-in-notebooks" title="Permalink to this headline">¶</a></h2>
    <p>Whether you have created an environment using conda like above, or created one from
    the conda file tab, the instructions for using an environment in that notebook
    are the same.</p>
    <p>When working in a notebook, to select the environment you have created and
    want to use with that notebook, from the top menu select the &#8220;Kernel&#8221; menu,
    then select &#8220;Change Kernel&#8221;.</p>
    <p>EXAMPLE: If you have an
    environment named &#8220;newenv&#8221; that includes numpy and scipy that you want to use
    in your notebook, from the notebook&#8217;s top Kernel menu select &#8220;Python [newenv]&#8221;.
    The code in the notebook will run in that environment and will be able to
    import numpy and scipy functions.</p>
    </div>
    <div class="section" id="customizing">
    <h2>Customizing<a class="headerlink" href="#customizing" title="Permalink to this headline">¶</a></h2>
    <p>If you need a Python package that Anaconda Enterprise Notebooks doesn&#8217;t
    include by default, you can easily install additional packages into your
    Anaconda Enterprise Notebooks environments.</p>
    <p>TIP: You cannot install packages into the default Anaconda
    environment. You must create your own environment, then install the new
    packages into that environment.</p>
    <p>Anaconda Enterprise Notebooks is built on Anaconda, so you can install
    additional Python packages using conda or pip, both of which
    are included with Anaconda.</p>
    <p>To install a Python package with conda, follow the above instructions to
    create and activate an environment. Then in your terminal, simply enter:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">conda</span> <span class="n">install</span> <span class="o">&lt;</span><span class="n">packagename</span><span class="o">&gt;</span>
    </pre></div>
    </div>
    <p>Specify the Python version you want when using conda to create the
    environment.</p>
    <p>EXAMPLE:</p>
    <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">conda</span> <span class="n">create</span> <span class="o">-</span><span class="n">n</span> <span class="n">mypy3</span> <span class="n">python</span><span class="o">=</span><span class="mi">3</span> <span class="n">numpy</span> <span class="n">scipy</span>
    </pre></div>
    </div>
    <p>This creates a conda environment named mypy3, running on Python 3 and
    containing NumPy and SciPy.</p>
    <p>All subsequent packages added to this environment will be the python 3
    compatible versions.</p>
    <p>TIP: You can also install the package within your notebook without using
    a terminal app. From Jupyter Notebook&#8217;s top menu select the conda file tab,
    click the environment you wish to use, search for the package you want,
    then click the Install button.</p>
    <p>If you prefer to use conda or pip in a terminal window, you can do so
    in Anaconda Enterprise Notebooks with the terminal application,
    just like you would on your local system.</p>
    <p>You can also uninstall a package using this method with &#8220;conda
    remove &lt;packagename&gt;&#8221;.</p>
    <p>See <a class="reference external" href="http://conda.pydata.org/docs/">conda</a> for full documentation on
    using conda with a terminal application.</p>
    </div>
