LinuxCommandLibrary

conda-create

Create new conda environments

TLDR

Create a new environment named py39, and install Python 3.9 and NumPy v1.11 or above in it

$ conda create [[-y|--yes]] [[-n|--name]] [py39] python=[3.9] "[numpy>=1.11]"
copy

Make exact copy of an environment
$ conda create --clone [py39] [[-n|--name]] [py39-copy]
copy

Create a new environment with a specified name and install a given package
$ conda create [[-n|--name]] [env_name] [package]
copy

SYNOPSIS

conda create [options] [package_spec ...]
conda create -n environment_name [package_spec ...]
conda create --prefix /path/to/env [package_spec ...]
conda create --file environment.yml
conda create --clone existing_env -n new_env_name

PARAMETERS

-n, --name <ENVIRONMENT_NAME>
    Specifies the name of the new environment. Environments created with a name are typically stored in your Conda installation's 'envs' directory.

-p, --prefix <PATH>
    Specifies the exact path to the new environment. This allows creating environments in custom locations.

package_spec [package_spec ...]
    One or more package specifications to install in the new environment (e.g., 'python=3.9', 'numpy', 'pandas').

-c, --channel <CHANNEL>
    Specifies an additional channel to search for packages. Can be used multiple times.

-y, --yes
    Do not ask for confirmation before proceeding with the creation process.

--clone <EXISTING_ENV>
    Clones an existing environment (specified by name or path) to create a new one with the same packages.

--file <PATH_TO_YAML>
    Reads package specifications and environment configurations from a YAML file (e.g., 'environment.yml').

--dry-run, -d
    Perform a dry run; only display what would have been done, without making any changes.

--override-channels
    Ignores the channels defined in the user's .condarc file and only uses the channels specified with --channel.

DESCRIPTION

The conda create command is a fundamental component of the Conda package, dependency, and environment management system. It enables users to set up new, isolated environments, each with its own independent set of installed Python versions, packages, and dependencies. This isolation is crucial for managing different projects that might require conflicting package versions or specific software configurations, preventing compatibility issues across your development work.

By using conda create, developers and researchers can ensure reproducible workflows, share specific environment configurations, and switch between different project contexts seamlessly. The command allows for high flexibility, from specifying exact Python versions to including a wide range of packages, including those beyond Python, such as R, Node.js, or system libraries.

CAVEATS

Environments created with conda create are isolated, meaning you must activate them using conda activate before you can use the packages installed within them. Creating many environments can consume significant disk space. While Conda manages dependencies, complex package specifications might sometimes lead to dependency conflicts, requiring manual intervention or adjustment of specified package versions. If no packages are explicitly specified, Conda typically installs a default set of packages, including Python and pip.

ENVIRONMENT LOCATION

Environments created using the -n or --name option are typically stored in the 'envs' directory within your main Conda installation path (e.g., '~/anaconda3/envs/' or '/opt/conda/envs/'). Environments created with the -p or --prefix option are placed exactly at the specified path.

BEST PRACTICES FOR REPRODUCIBILITY

For reproducible environments, it is highly recommended to use --file with an environment.yml file. This YAML file lists all desired packages and their versions, ensuring that anyone can recreate the exact same environment. Always pin package versions (e.g., 'python=3.9.7', 'numpy=1.23.0') to avoid unexpected breaking changes from future package updates.

HISTORY

Conda was first released in 2012 by Continuum Analytics (now Anaconda Inc.), primarily to address the challenges of managing scientific computing packages and their complex dependencies. The conda create command has been a cornerstone of Conda since its early days, facilitating the crucial isolation of environments. Its ability to manage non-Python packages, unlike Python-specific tools like pip and virtualenv, marked a significant advancement in package and environment management within the scientific and data science communities.

SEE ALSO

conda activate(1), conda env list(1), conda install(1), conda remove(1), conda update(1), pip(1), virtualenv(1)

Copied to clipboard