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 [-n|--name] ENV_NAME [package_spec]...

PARAMETERS

-n, --name ENV_NAME
    The name of the environment to create. If this option is not used, conda will create an environment in the default location, usually a directory named `envs` within the user's home directory.

package_spec
    One or more packages to install in the new environment. You can specify package names, versions, or channel specifications. For example: `python=3.9`, `numpy`, `conda-forge::pandas`.

-c, --channel CHANNEL
    The channel to search for packages. Conda uses the 'defaults' channel by default. Multiple channels can be specified.

--override-channels
    Do not search default or conda-forge channels. Requires -c or --channel.

-f, --file FILE
    Read package specs from the given file. Useful for creating environments from a pre-defined list of dependencies.

--clone ENVIRONMENT
    Clone an existing environment. Creates a new environment with the same packages as the specified environment.

--offline
    Use packages from the local cache only. Do not connect to online repositories.

-p, --prefix PREFIX
    Full path to environment location (i.e. /opt/conda/envs/foo).

-q, --quiet
    Do not display progress bar.

-y, --yes
    Do not ask for confirmation. Assume 'yes' as answer to all prompts.

--no-default-packages
    Ignore create_default_packages in .condarc file.

--no-shortcuts
    Do not install start menu shortcuts (Windows only).

--mkdir
    Create prefix directory.

DESCRIPTION

The `conda create` command creates a new conda environment from the command line. A conda environment is a directory that contains a specific collection of conda packages that you have installed. This isolates different project dependencies allowing you to have different versions of packages for different projects without conflicts. You can specify the name of the environment, the Python version to use, and the packages to install when creating the environment. It is used to manage isolated environments where one can install libraries with particular versions avoiding conflicts with other projects.

Conda environments are essential for reproducibility and dependency management in data science and software development projects. Properly utilizing `conda create` avoids versioning conflicts.

CAVEATS

Creating an environment with a specific Python version may not always succeed if the requested version is not available in the configured channels. Ensure your channels are properly configured and up-to-date.

Conda environments take up disk space, so regularly review and remove unused environments to free up storage.

EXAMPLES

Create a new environment named 'myenv' with Python 3.9:
`conda create -n myenv python=3.9`

Create a new environment with numpy:
`conda create -n myenv numpy`

Create a new environment from a file:
`conda create -n myenv -f environment.yml`

Clone an existing environment:
`conda create -n newenv --clone oldenv`

ENVIRONMENT VARIABLES

The `conda create` command respects environment variables like `CONDA_ENVS_DIRS` which specifies the directories where environments will be created. The value of this variable will override the default envs path.

HISTORY

Conda was created by Continuum Analytics (now Anaconda Inc.) to address the challenges of managing dependencies and environments in data science workflows. The `conda create` command has been a fundamental part of Conda since its early versions, providing a consistent way to create isolated environments and manage package installations. Over time, the command has been enhanced with features like channel specification, cloning, and file-based dependency management.

SEE ALSO

conda env(1), conda activate(1), conda deactivate(1), conda list(1), conda remove(1), conda update(1)

Copied to clipboard