LinuxCommandLibrary

conda-create

Create new conda environments

TLDR

Create a new environment named py39, install Python 3.9, NumPy v1.11 or above in it, and the latest stable version of SciPy. Say yes to all confirmations

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

Create a new environment named myenv and install packages listed in files
$ conda create [[-n|--name]] myenv --file [file1.yml] --file [file2.yml]
copy

Create a new environment named myenv at custom path (i.e. prefix)
$ conda create [[-p|--prefix]] [path/to/myenv]
copy

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

Display help
$ conda create [[-h|--help]]
copy

SYNOPSIS

conda create [options] [--name] ENV [package[=version] [package[=version] ...]]

PARAMETERS

--name
    Name of the new environment (default location: envs/NAME)

--prefix
    Full path to the new environment directory

--clone
    Name or path of environment to clone from

--file, -f
    Path to YAML or text requirements file

--dry-run
    Show plan without installing

--json
    Output in JSON format

--offline
    Use only cached packages (no downloads)

--use-local
    Use locally built packages

--no-default-packages
    Skip installing default packages like pip

--experimental-solver
    Enable faster experimental solver

--copy
    Copy files instead of hard-linking when cloning

--force
    Allow clobbering existing files

-q, --quiet
    Minimal output

DESCRIPTION

The conda create command initializes a new virtual environment in the Conda package and environment manager, commonly used in scientific computing, data science, and Python development on Linux. Conda environments allow users to isolate dependencies for different projects, preventing conflicts between package versions.

By default, environments are created in the envs subdirectory of the active Conda directory (often ~/.conda/envs). Users specify an environment name with --name or a full path with --prefix. Packages can be installed during creation by listing them as arguments, e.g., python=3.10 numpy, which resolves compatible versions from configured channels like defaults or conda-forge.

This command fetches and installs packages, creating a self-contained space with its own Python interpreter, binaries, and libraries. It's faster and more reliable than pip for complex dependencies involving non-Python libraries like MKL or CUDA. Activation via conda activate switches to the environment, modifying PATH seamlessly. Ideal for reproducible workflows, as environments can be exported to environment.yml files.

CAVEATS

Requires Conda installation (via Miniconda/Anaconda). Large environments consume significant disk space. Solver may take time for complex specs; use --experimental-solver for speedups. Not compatible with pip-installed packages in same env without care.

COMMON USAGE

conda create --name myenv python=3.11 numpy pandas
conda create -p /path/to/myenv --file environment.yml

ACTIVATION

After creation: source activate myenv or conda activate myenv (Bash). Deactivate with conda deactivate.

HISTORY

Developed by Continuum Analytics (now Anaconda Inc.) as part of Conda 0.1 in 2012. Evolved with multi-language support (Python, R, etc.) and solver improvements in Conda 4.0+ (2016). Widely adopted in HPC and ML workflows.

SEE ALSO

conda(1), conda activate(1), conda install(1), conda env export(1)

Copied to clipboard