Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/conda/conda/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The conda env export command exports a given environment’s package specifications to a file or stdout. This is essential for creating reproducible environments and sharing environment specifications with others.
This command is also available as conda export (without the env subcommand).

Syntax

conda env export [options]
By default, exports the currently active environment to stdout in YAML format.

Target Environment Specification

-n, --name
string
Name of environment to export. If not specified, exports the currently active environment.
-p, --prefix
string
Full path to environment location (i.e. prefix) to export.

Output Options

-f, --file
string
File name or path for the exported environment.
This will silently overwrite any existing file of the same name in the current directory.
--format
string
Format for the exported environment. Available formats depend on installed plugins.Common formats:
  • yaml or environment-yaml - Standard YAML format (default)
  • json or environment-json - JSON format
If not specified, format is determined by:
  1. File extension (if --file is used)
  2. Default to YAML
--json
boolean
For backwards compatibility: when used without --format and without --file, exports in JSON format.If used with --file, only affects status messages (not the export format).

Channel Options

-c, --channel
string
Additional channel to include in the export. Can be specified multiple times.
-O, --override-channels
boolean
Do not include .condarc channels in the export.
--ignore-channels
boolean
default:false
Do not include channel names with package names in the export.
Use this when you want package specifications without channel prefixes (e.g., numpy instead of conda-forge::numpy).

Platform Options

--platform, --subdir
string
Target platform(s)/subdir(s) for export (e.g., linux-64, osx-64, win-64). Can be specified multiple times for multi-platform exports.
Multi-platform export is only supported by certain exporters (like environment-yaml).
--override-platforms
boolean
Override the platforms specified in the condarc.

Package Specification Options

--from-history
boolean
default:false
Build environment spec from explicit specs in history (packages you explicitly installed) rather than all packages.
Recommended for creating portable, minimal environment specifications. This exports only the packages you explicitly requested, not their dependencies.
--no-builds
boolean
default:false
Remove build specification from dependencies. This makes the export more portable across platforms.Example:
  • With builds: numpy=1.24.0=py311h1234567_0
  • Without builds: numpy=1.24.0

Output Control

-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.

Export Formats

YAML Format (Default)

The standard conda environment format:
name: myenv
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.11.0=h1234567_0
  - numpy=1.24.0=py311h1234567_0
  - pandas=1.5.3=py311h1234567_0
  - pip:
    - requests==2.28.2
prefix: /home/user/miniconda3/envs/myenv

JSON Format

Structured JSON output:
{
  "name": "myenv",
  "channels": [
    "conda-forge",
    "defaults"
  ],
  "dependencies": [
    "python=3.11.0=h1234567_0",
    "numpy=1.24.0=py311h1234567_0"
  ],
  "prefix": "/home/user/miniconda3/envs/myenv"
}

Examples

Export current environment to stdout

conda env export
Exports the active environment in YAML format to the terminal.

Export to a file

conda env export --file environment.yml
Exports to environment.yml in the current directory.

Export specific environment

conda env export -n myenv --file myenv.yml
Exports the myenv environment to a file.

Export with minimal specification

conda env export --from-history --file environment.yml
Exports only explicitly installed packages (recommended for portability).

Export without build strings

conda env export --no-builds --file environment.yml
Exports without platform-specific build identifiers.

Export in JSON format

conda env export --format json --file environment.json
or for backwards compatibility:
conda env export --json > environment.json

Export without channels

conda env export --ignore-channels --file environment.yml
Exports packages without channel prefixes.

Export for multiple platforms

conda env export --platform linux-64 --platform osx-64 --file environment.yml
Creates a multi-platform environment file.

Export from history without builds

conda env export --from-history --no-builds --file environment.yml
Creates the most portable environment specification.

Common Use Cases

Export a minimal, portable specification:
conda env export --from-history --no-builds --file environment.yml
Team members can recreate with:
conda env create -f environment.yml
Export with full specifications for exact reproduction:
conda env export --file environment-exact.yml
This includes all dependencies with exact versions and builds.
Export without build strings for cross-platform compatibility:
conda env export --no-builds --from-history --file environment.yml
Create minimal environment file for version control:
conda env export --from-history --no-builds --file environment.yml
git add environment.yml
git commit -m "Add environment specification"
Backup environment before updates:
conda env export --file backup-$(date +%Y%m%d).yml
conda update --all
Export for reproducible testing:
conda env export --from-history --no-builds --file ci-environment.yml

Export Strategies

Minimal Export

Best for: Sharing and version control
conda env export --from-history --no-builds
  • Only explicitly installed packages
  • No build strings
  • Most portable

Complete Export

Best for: Exact reproduction
conda env export
  • All packages including dependencies
  • Full version and build specs
  • Platform-specific

Cross-Platform Export

Best for: Multi-platform projects
conda env export --no-builds --from-history
  • Works across different operating systems
  • No platform-specific builds

Channel-Free Export

Best for: Flexibility
conda env export --ignore-channels --from-history
  • No channel specifications
  • Allows conda to choose best sources

Understanding Export Options

—from-history vs Full Export

Full export (default):
dependencies:
  - python=3.11.0=h1234567_0
  - numpy=1.24.0=py311h1234567_0
  - pandas=1.5.3=py311h1234567_0
  - pytz=2022.7.1=py311h1234567_0  # pandas dependency
  - python-dateutil=2.8.2=pyhd8ed1ab_0  # pandas dependency
With —from-history:
dependencies:
  - python=3.11
  - numpy
  - pandas

—no-builds Effect

With builds:
- numpy=1.24.0=py311h1234567_0
Without builds:
- numpy=1.24.0

Troubleshooting

Use --from-history to export only explicitly installed packages:
conda env export --from-history --file environment.yml
Remove build strings and use history:
conda env export --from-history --no-builds --file environment.yml
Ensure you’re specifying valid platforms:
conda env export --platform linux-64 --platform osx-64 --platform win-64
Valid platforms: linux-64, linux-aarch64, osx-64, osx-arm64, win-64
The command will silently overwrite. To be safe:
# Backup first
cp environment.yml environment-backup.yml
# Then export
conda env export --file environment.yml

Best Practices

  1. Version Control: Use --from-history --no-builds for files in version control
  2. Documentation: Add comments to exported YAML files to explain special packages
  3. Regular Updates: Export environment specifications regularly as your project evolves
  4. Multiple Formats: Keep both minimal and complete exports for different purposes
  5. Platform Specificity: Use --platform when you know the target platforms