Skip to main content

Overview

The conda env create command creates a new conda environment from an environment definition file (typically environment.yml). This is the recommended way to create reproducible environments from a specification file.

Syntax

conda env create [options]
By default, conda env create looks for a file named environment.yml in the current directory. Use -f to specify a different file.

Target Environment Specification

-n, --name
string
Name of environment. Overrides the name specified in the environment.yml file.
-p, --prefix
string
Full path to environment location (i.e. prefix). Use this to create the environment at a specific location.

File Options

-f, --file
string
default:"environment.yml"
Environment definition file. Can be:
  • environment.yml - Conda environment specification
  • requirements.txt - Pip-style requirements file
  • Any file supported by environment specifier plugins
You can specify the file path relative to your current directory or use an absolute path.

Channel Customization

-c, --channel
string
Additional channel to search for packages. Can be specified multiple times.
--use-local
boolean
Use locally built packages. Identical to ‘-c local’.
-O, --override-channels
boolean
Do not search default or .condarc channels. Requires --channel.

Environment Specifier Options

--environment-specifier
string
Specify which environment specifier plugin to use for parsing the environment file.

Solver Options

--solver
string
Choose which solver backend to use.

Platform Options

--platform, --subdir
string
Target platform/subdir for the environment (e.g., linux-64, osx-64, win-64).

Package Options

--no-default-packages
boolean
Do not install default packages (specified in .condarc). Only install packages explicitly listed in the environment file.

Output and Prompt Options

--json
boolean
Report all output as JSON. Suitable for using conda programmatically.
-d, --dry-run
boolean
Only display what would have been done. Outputs the solved environment specification without actually creating the environment.
-y, --yes
boolean
Sets any confirmation values to ‘yes’ automatically. If the environment already exists at the target location, it will be removed and recreated.
-v, --verbose
boolean
Can be used multiple times. Once for INFO, twice for DEBUG, three times for TRACE.
-q, --quiet
boolean
Do not display progress bar.

Networking Options

-C, --use-index-cache
boolean
Use cache of channel index files, even if it has expired.
-k, --insecure
boolean
Allow conda to perform “insecure” SSL connections and transfers.
--offline
boolean
Offline mode. Don’t connect to the Internet.

Environment File Format

YAML Format (environment.yml)

The standard conda environment file uses YAML format:
name: myenv
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.11
  - numpy
  - pandas>=1.5
  - pip
  - pip:
    - requests
    - flask
variables:
  DATABASE_URL: postgresql://localhost/mydb
  DEBUG: "true"

Requirements.txt Format

You can also use pip-style requirements.txt:
numpy==1.24.0
pandas>=1.5.0
requests

Examples

Create environment from default file

conda env create
Creates an environment from environment.yml in the current directory.

Create with custom environment name

conda env create -n myenv
Creates an environment named myenv, overriding the name in the file.

Create from specific file

conda env create -f /path/to/environment.yml
Creates an environment from a file at a specific location.

Create from requirements.txt

conda env create -f requirements.txt -n myenv
Creates an environment from a pip requirements file.

Create at specific location

conda env create -f environment.yml -p /home/user/envs/myenv
Creates the environment at the specified path.

Dry run to preview changes

conda env create --dry-run
Shows what would be installed without actually creating the environment.

Create with additional channel

conda env create -f environment.yml -c conda-forge
Adds conda-forge channel in addition to channels specified in the file.

Create without default packages

conda env create -f environment.yml --no-default-packages
Creates environment with only packages specified in the file, ignoring default packages from .condarc.

Common Use Cases

Share environment.yml with your team for consistent environments:
name: data-project
channels:
  - conda-forge
dependencies:
  - python=3.11
  - pandas=2.0
  - scikit-learn=1.3
  - jupyter
conda env create -f environment.yml
Create environments that work across different platforms:
name: cross-platform
channels:
  - conda-forge
dependencies:
  - python=3.11
  - numpy
  - pandas
The solver will automatically select appropriate packages for your platform.
Set environment variables automatically:
name: web-app
dependencies:
  - python=3.11
  - flask
variables:
  FLASK_APP: app.py
  FLASK_ENV: development
Combine conda and pip packages:
name: mixed-deps
dependencies:
  - python=3.11
  - numpy
  - pip
  - pip:
    - requests
    - some-pip-only-package
Create environments from files hosted online:
conda env create -f https://raw.githubusercontent.com/user/repo/main/environment.yml

Behavior Notes

Existing Environment HandlingIf an environment with the same name already exists:
  • Without -y flag: You’ll be prompted to remove and recreate it
  • With -y flag: The existing environment will be automatically removed and recreated
Name PriorityWhen both the file and command line specify a name:
  1. Command line -n/--name takes precedence
  2. File’s name: field is used if no command line name
  3. If neither is specified, you must provide one
Platform-Specific PackagesIf the subdir is different from the native platform, conda will write it to the environment’s .condarc file for future operations.

Troubleshooting

Ensure either:
  • Your environment.yml has a name: field
  • You provide -n or -p flag
conda env create -n myenv -f environment.yml
Check that the file exists and the path is correct:
ls -l environment.yml
conda env create -f ./environment.yml
Use --dry-run to see what will be installed:
conda env create --dry-run

Build docs developers (and LLMs) love