conda env create: Usage, Options & Common CI Errors
conda env create builds a complete environment from an environment.yml spec.
conda env create is the declarative path: define dependencies in environment.yml and reproduce the exact environment in CI. It is more reproducible than a chain of conda install commands.
What it does
conda env create reads an environment.yml (name, channels, dependencies including pip sub-deps) and builds the environment in one solve. It is the standard way to provision a data/ML environment in CI. Re-running it fails if the environment already exists unless you remove it or use update.
Common usage
conda env create -f environment.yml
conda env create -f environment.yml -n ci-env # override the name
conda env update -f environment.yml --prune # update an existing env
conda env create --prefix ./envs/ci -f environment.yml
conda activate ci-envCommon errors in CI
"CondaValueError: prefix already exists" - the env exists from a cached layer; use conda env update -f ... --prune, or conda env remove -n NAME first. "ResolvePackageNotFound" lists packages the solver could not satisfy (often a platform-specific pin or a missing channel) - fix the channels/pins in environment.yml. A long stall on "Solving environment" is the slow classic solver; set the libmamba solver. pip sub-dependencies in the YAML run after conda and can fail separately.
Options
| Flag | What it does |
|---|---|
| -f <file> | Spec file (default environment.yml) |
| -n <name> | Override the environment name |
| --prefix <path> | Create the env at a path instead of by name |
| env update --prune | Update env and remove dropped deps |
| env remove -n <name> | Delete an environment |