"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/source/user-guide/tasks/manage-environments.rst" between
conda-4.6.2.tar.gz and conda-4.6.3.tar.gz

About: Conda is a cross-platform, language-agnostic, system-level binary package manager and ecosystem.

manage-environments.rst  (conda-4.6.2):manage-environments.rst  (conda-4.6.3)
===================== =====================
Managing environments Managing environments
===================== =====================
.. contents:: .. contents::
:local: :local:
:depth: 1 :depth: 1
With conda, you can create, export, list, remove and update With conda, you can create, export, list, remove, and update
environments that have different versions of Python and/or environments that have different versions of Python and/or
packages installed in them. Switching or moving between packages installed in them. Switching or moving between
environments is called activating the environment. You can also environments is called activating the environment. You can also
share an environment file. share an environment file.
NOTE: There are many options available for the commands described NOTE: There are many options available for the commands described
on this page. For details, see :doc:`../../commands`. on this page. For details, see :doc:`../../commands`.
NOTE: ``conda activate`` and ``conda deactivate`` only work on conda 4.6 and lat
er versions.
For conda versions prior to 4.6, run:
* Windows: ``activate`` or ``deactivate``
* Linux and macOS: ``source activate`` or ``source deactivate``
Creating an environment with commands Creating an environment with commands
===================================== =====================================
TIP: By default, environments are installed into the ``envs`` TIP: By default, environments are installed into the ``envs``
directory in your conda directory. Run ``conda create --help`` directory in your conda directory. Run ``conda create --help``
for information on specifying a different path. for information on specifying a different path.
Use the Terminal or an Anaconda Prompt for the following steps. Use the terminal or an Anaconda Prompt for the following steps.
#. To create an environment: #. To create an environment:
.. code:: .. code::
conda create --name myenv conda create --name myenv
NOTE: Replace ``myenv`` with the environment name. NOTE: Replace ``myenv`` with the environment name.
#. When conda asks you to proceed, type ``y``: #. When conda asks you to proceed, type ``y``:
.. code:: .. code::
proceed ([y]/n)? proceed ([y]/n)?
This creates the myenv environment in ``/envs/``. This This creates the myenv environment in ``/envs/``. This
environment uses the same version of Python that you are environment uses the same version of Python that you are
currently using, because you did not specify a version. currently using because you did not specify a version.
To create an environment with a specific version of Python: To create an environment with a specific version of Python:
.. code-block:: bash .. code-block:: bash
conda create -n myenv python=3.4 conda create -n myenv python=3.4
To create an environment with a specific package: To create an environment with a specific package:
.. code-block:: bash .. code-block:: bash
skipping to change at line 108 skipping to change at line 114
conda create --no-default-packages -n myenv python conda create --no-default-packages -n myenv python
TIP: You can add much more to the ``conda create`` command. TIP: You can add much more to the ``conda create`` command.
For details, run ``conda create --help``. For details, run ``conda create --help``.
.. _create-env-from-file: .. _create-env-from-file:
Creating an environment from an environment.yml file Creating an environment from an environment.yml file
==================================================== ====================================================
Use the Terminal or an Anaconda Prompt for the following steps. Use the terminal or an Anaconda Prompt for the following steps.
#. Create the environment from the ``environment.yml`` file: #. Create the environment from the ``environment.yml`` file:
.. code:: .. code::
conda env create -f environment.yml conda env create -f environment.yml
The first line of the ``yml`` file sets the new environment's The first line of the ``yml`` file sets the new environment's
name. For details see :ref:`Creating an environment file manually name. For details see :ref:`Creating an environment file manually
<create-env-file-manually>`. <create-env-file-manually>`.
#. Activate the new environment:
* Windows: ``activate myenv`` #. Activate the new environment: ``conda activate myenv``
* macOS and Linux: ``source activate myenv`` NOTE: Replace ``myenv`` with the environment name.
NOTE: Replace ``myenv`` with the name of the environment.
#. Verify that the new environment was installed correctly: #. Verify that the new environment was installed correctly:
.. code:: .. code::
conda list conda list
Cloning an environment Cloning an environment
======================= =======================
Use the Terminal or an Anaconda Prompt for the following steps. Use the terminal or an Anaconda Prompt for the following steps.
You can make an exact copy of an environment by creating a clone You can make an exact copy of an environment by creating a clone
of it: of it:
.. code:: .. code::
conda create --name myclone --clone myenv conda create --name myclone --clone myenv
NOTE: Replace ``myclone`` with the name of the new environment. NOTE: Replace ``myclone`` with the name of the new environment.
Replace ``myenv`` with the name of the existing environment that Replace ``myenv`` with the name of the existing environment that
skipping to change at line 166 skipping to change at line 168
In the environments list that displays, you should see both the In the environments list that displays, you should see both the
source environment and the new copy. source environment and the new copy.
Building identical conda environments Building identical conda environments
===================================== =====================================
You can use explicit specification files to build an identical You can use explicit specification files to build an identical
conda environment on the same operating system platform, either conda environment on the same operating system platform, either
on the same machine or on a different machine. on the same machine or on a different machine.
Use the Terminal or an Anaconda Prompt for the following steps. Use the terminal or an Anaconda Prompt for the following steps.
#. Run ``conda list --explicit`` to produce a spec list such as: #. Run ``conda list --explicit`` to produce a spec list such as:
.. code:: .. code::
# This file may be used to create an environment using: # This file may be used to create an environment using:
# $ conda create --name <env> --file <this file> # $ conda create --name <env> --file <this file>
# platform: osx-64 # platform: osx-64
@EXPLICIT @EXPLICIT
https://repo.continuum.io/pkgs/free/osx-64/mkl-11.3.3-0.tar.bz2 https://repo.continuum.io/pkgs/free/osx-64/mkl-11.3.3-0.tar.bz2
skipping to change at line 226 skipping to change at line 228
from a spec file. To ensure that the packages work correctly, from a spec file. To ensure that the packages work correctly,
make sure that the file was created from a working environment, make sure that the file was created from a working environment,
and use it on the same architecture, operating system and and use it on the same architecture, operating system and
platform, such as linux-64 or osx-64. platform, such as linux-64 or osx-64.
.. _activate-env: .. _activate-env:
Activating an environment Activating an environment
========================= =========================
To activate an environment: To activate an environment: ``conda activate myenv``
* On Windows, in your Anaconda Prompt, run ``activate myenv``
* On macOS and Linux, in your Terminal Window, run ``source activate myenv`` NOTE: Replace ``myenv`` with the environment name.
Conda prepends the path name ``myenv`` onto your system command. Conda prepends the path name ``myenv`` onto your system command.
Deactivating an environment Deactivating an environment
=========================== ===========================
To deactivate an environment: To deactivate an environment, type: ``conda deactivate``
* On Windows, in your Anaconda Prompt, run ``deactivate``
* On macOS and Linux, in your Terminal Window, run ``source deactivate`` NOTE: Replace ``myenv`` with the environment name.
Conda removes the path name ``myenv`` from your system command. Conda removes the path name ``myenv`` from your system command.
TIP: In Windows, it is good practice to deactivate one TIP: In Windows, it is good practice to deactivate one
environment before activating another. environment before activating another.
.. _determine-current-env: .. _determine-current-env:
Determining your current environment Determining your current environment
==================================== ====================================
Use the Terminal or an Anaconda Prompt for the following steps. Use the terminal or an Anaconda Prompt for the following steps.
By default, the active environment---the one you are currently By default, the active environment---the one you are currently
using---is shown in parentheses () or brackets [] at the using---is shown in parentheses () or brackets [] at the
beginning of your command prompt:: beginning of your command prompt::
(myenv) $ (myenv) $
If you do not see this, run: If you do not see this, run:
.. code:: .. code::
skipping to change at line 282 skipping to change at line 280
conda config --set changeps1 false conda config --set changeps1 false
To re-enable this option:: To re-enable this option::
conda config --set changeps1 true conda config --set changeps1 true
Viewing a list of your environments Viewing a list of your environments
=================================== ===================================
To see a list of all of your environments, in your Terminal window or an To see a list of all of your environments, in your terminal window or an
Anaconda Prompt, run: Anaconda Prompt, run:
.. code:: .. code::
conda info --envs conda info --envs
OR OR
.. code:: .. code::
skipping to change at line 309 skipping to change at line 307
conda environments: conda environments:
myenv /home/username/miniconda/envs/myenv myenv /home/username/miniconda/envs/myenv
snowflakes /home/username/miniconda/envs/snowflakes snowflakes /home/username/miniconda/envs/snowflakes
bunnies /home/username/miniconda/envs/bunnies bunnies /home/username/miniconda/envs/bunnies
Viewing a list of the packages in an environment Viewing a list of the packages in an environment
================================================ ================================================
To see a list of all packages installed in a specific environment: To see a list of all packages installed in a specific environment:
* If the environment is not activated, in your Terminal window or an * If the environment is not activated, in your terminal window or an
Anaconda Prompt, run: Anaconda Prompt, run:
.. code-block:: bash .. code-block:: bash
conda list -n myenv conda list -n myenv
* If the environment is activated, in your Terminal window or an * If the environment is activated, in your terminal window or an
Anaconda Prompt, run: Anaconda Prompt, run:
.. code-block:: bash .. code-block:: bash
conda list conda list
To see if a specific package is installed in an environment, in your Terminal wi ndow or an To see if a specific package is installed in an environment, in your terminal wi ndow or an
Anaconda Prompt, run: Anaconda Prompt, run:
.. code-block:: bash .. code-block:: bash
conda list -n myenv scipy conda list -n myenv scipy
.. _pip-in-env: .. _pip-in-env:
Using pip in an environment Using pip in an environment
=========================== ===========================
To use pip in your environment, in your Terminal window or an To use pip in your environment, in your terminal window or an
Anaconda Prompt, run: Anaconda Prompt, run:
.. code-block:: bash .. code-block:: bash
conda install -n myenv pip conda install -n myenv pip
source activate myenv conda activate myenv
pip <pip_subcommand> pip <pip_subcommand>
Saving environment variables Saving environment variables
============================ ============================
Conda environments can include saved environment variables. Conda environments can include saved environment variables.
Suppose you want an environment "analytics" to store both a Suppose you want an environment "analytics" to store both a
secret key needed to log in to a server and a path to a secret key needed to log in to a server and a path to a
configuration file. The sections below explain how to write a configuration file. The sections below explain how to write a
skipping to change at line 394 skipping to change at line 392
#. Edit ``.\etc\conda\activate.d\env_vars.bat`` as follows:: #. Edit ``.\etc\conda\activate.d\env_vars.bat`` as follows::
set MY_KEY='secret-key-value' set MY_KEY='secret-key-value'
set MY_FILE=C:\path\to\my\file set MY_FILE=C:\path\to\my\file
#. Edit ``.\etc\conda\deactivate.d\env_vars.bat`` as follows:: #. Edit ``.\etc\conda\deactivate.d\env_vars.bat`` as follows::
set MY_KEY= set MY_KEY=
set MY_FILE= set MY_FILE=
When you run ``activate analytics``, the environment variables When you run ``conda activate analytics``, the environment variables
MY_KEY and MY_FILE are set to the values you wrote into the file. MY_KEY and MY_FILE are set to the values you wrote into the file.
When you run ``deactivate``, those variables are erased. When you run ``conda deactivate``, those variables are erased.
.. _macos-linux-save-env-variables: .. _macos-linux-save-env-variables:
macOS and Linux macOS and Linux
--------------- ---------------
#. Locate the directory for the conda environment in your Terminal window by run ning in the terminal ``echo $CONDA_PREFIX``. #. Locate the directory for the conda environment in your terminal window by run ning in the terminal ``echo $CONDA_PREFIX``.
#. Enter that directory and create these subdirectories and #. Enter that directory and create these subdirectories and
files:: files::
cd $CONDA_PREFIX cd $CONDA_PREFIX
mkdir -p ./etc/conda/activate.d mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d mkdir -p ./etc/conda/deactivate.d
touch ./etc/conda/activate.d/env_vars.sh touch ./etc/conda/activate.d/env_vars.sh
touch ./etc/conda/deactivate.d/env_vars.sh touch ./etc/conda/deactivate.d/env_vars.sh
skipping to change at line 428 skipping to change at line 426
export MY_KEY='secret-key-value' export MY_KEY='secret-key-value'
export MY_FILE=/path/to/my/file/ export MY_FILE=/path/to/my/file/
#. Edit ``./etc/conda/deactivate.d/env_vars.sh`` as follows:: #. Edit ``./etc/conda/deactivate.d/env_vars.sh`` as follows::
#!/bin/sh #!/bin/sh
unset MY_KEY unset MY_KEY
unset MY_FILE unset MY_FILE
When you run ``source activate analytics``, the environment When you run ``conda activate analytics``, the environment
variables MY_KEY and MY_FILE are set to the values you wrote into variables MY_KEY and MY_FILE are set to the values you wrote into
the file. When you run ``source deactivate``, those variables are the file. When you run ``conda deactivate``, those variables are
erased. erased.
Sharing an environment Sharing an environment
======================= =======================
You may want to share your environment with someone else---for You may want to share your environment with someone else---for
example, so they can re-create a test that you have done. To example, so they can re-create a test that you have done. To
allow them to quickly reproduce your environment, with all of its allow them to quickly reproduce your environment, with all of its
packages and versions, give them a copy of your packages and versions, give them a copy of your
``environment.yml file``. ``environment.yml file``.
Exporting the environment file Exporting the environment file
------------------------------- -------------------------------
NOTE: If you already have an ``environment.yml`` file in your NOTE: If you already have an ``environment.yml`` file in your
current directory, it will be overwritten during this task. current directory, it will be overwritten during this task.
#. Activate the environment to export: #. Activate the environment to export: ``conda activate myenv``
* On Windows, in your Anaconda Prompt, run ``activate myenv``
* On macOS and Linux, in your Terminal window, run ``source activate myenv``
NOTE: Replace ``myenv`` with the name of the environment. NOTE: Replace ``myenv`` with the name of the environment.
#. Export your active environment to a new file:: #. Export your active environment to a new file::
conda env export > environment.yml conda env export > environment.yml
NOTE: This file handles both the environment's pip packages NOTE: This file handles both the environment's pip packages
and conda packages. and conda packages.
skipping to change at line 522 skipping to change at line 516
list <config-channels>` in the ``.condarc`` file. However, list <config-channels>` in the ``.condarc`` file. However,
changing ``environment.yml`` affects only one of your conda changing ``environment.yml`` affects only one of your conda
environments while changing ``.condarc`` affects them all. environments while changing ``.condarc`` affects them all.
For details on creating an environment from this For details on creating an environment from this
``environment.yml`` file, see :ref:`create-env-from-file`. ``environment.yml`` file, see :ref:`create-env-from-file`.
Removing an environment Removing an environment
======================= =======================
To remove an environment, in your Terminal window or an To remove an environment, in your terminal window or an
Anaconda Prompt, run: Anaconda Prompt, run:
.. code:: .. code::
conda remove --name myenv --all conda remove --name myenv --all
(You may instead use ``conda env remove --name myenv``.) (You may instead use ``conda env remove --name myenv``.)
To verify that the environment was removed, in your Terminal window or an To verify that the environment was removed, in your terminal window or an
Anaconda Prompt, run: Anaconda Prompt, run:
.. code:: .. code::
conda info --envs conda info --envs
The environments list that displays should not show the removed The environments list that displays should not show the removed
environment. environment.
 End of changes. 29 change blocks. 
42 lines changed or deleted 37 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)