LinuxCommandLibrary

conda-env

Manage Conda environments

TLDR

Create an environment from an environment file (YAML, TXT, etc.)

$ conda env create [[-f|--file]] [path/to/file]
copy

Delete an environment and everything in it
$ conda env remove [[-n|--name]] [environment_name]
copy

Update an environment based on an environment file
$ conda env update [[-f|--file]] [path/to/file] --prune
copy

List all environments
$ conda env list
copy

View environment details
$ conda env export
copy

List environment variables
$ conda env config vars list
copy

Set environment variables
$ conda env config vars set [my_var]=[value]
copy

SYNOPSIS

conda env <list | create | update | remove | export | config> [options] [arguments]

PARAMETERS

list, ls
    Lists all known conda environments.

create
    Creates a new conda environment.

update
    Updates an existing conda environment.

remove, rm
    Removes a specified conda environment.

export
    Exports the specification of an environment to a YAML file.

config
    Modifies conda environment configurations.

-h, --help
    Shows a help message for the command or subcommand.

-n <name>, --name <name>
    Specifies the name of the environment to operate on.

-f <file>, --file <file>
    Specifies the path to an environment.yml file for creating or updating an environment.

-y, --yes
    Do not ask for confirmation on any prompt during an operation.

--verbose, --debug
    Increases the verbosity of the output, showing more detailed information for debugging.

DESCRIPTION

conda env is a subcommand of the conda package, dependency, and environment manager. It allows users to create, list, activate, deactivate, update, and remove isolated environments. These environments are crucial for managing different sets of packages and their dependencies without conflicts, especially when working on multiple projects that require different versions of Python or other libraries. For instance, one project might need Python 3.8 with TensorFlow 2.x, while another requires Python 3.10 with PyTorch 1.x. conda env provides the tools to switch between these configurations seamlessly. It supports creating environments from environment.yml files, making environments reproducible and shareable. This capability is fundamental for scientific computing, data science, and software development, ensuring consistent project setups across various machines and collaborators. It significantly enhances productivity and reduces dependency-related issues across diverse development tasks.

CAVEATS


conda env is a subcommand, meaning it must be invoked as conda env, not as a standalone executable.
Environments can consume significant disk space, especially with many environments or large packages.
Activating and deactivating environments modifies your shell's environment variables; ensure proper shell initialization.
Mixing package managers (e.g., pip and conda) indiscriminately within a single environment can lead to dependency conflicts.

<I>ACTIVATION AND DEACTIVATION</I>

To use an environment, it must be activated using conda activate <environment_name>. This modifies your shell's PATH and other environment variables to point to the packages within that specific environment. To exit an environment and return to the base environment, use conda deactivate.

<I>ENVIRONMENT FILES (ENVIRONMENT.YML)</I>

environment.yml files are YAML-formatted manifests that specify an environment's name, channels, and dependencies (packages). They are crucial for creating reproducible environments and sharing them with others. You can create an environment from a file using conda env create -f environment.yml and export an existing environment to a file using conda env export > environment.yml.

HISTORY

conda was developed by Continuum Analytics (now Anaconda, Inc.) starting around 2012. The conda env subcommand was introduced as a core feature to provide a robust and cross-platform way to manage isolated environments, extending beyond just Python to include any language or package. It became fundamental in the scientific computing and data science communities, addressing the challenges of dependency management and reproducibility. Its capability to create environments from environment.yml files has been a pivotal feature for collaboration and deployment, making consistent project setups achievable across diverse development environments.

SEE ALSO

conda(1), pip(1), virtualenv(1), venv(1), docker(1)

Copied to clipboard