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
Theconda env update command updates an existing conda environment based on an environment definition file. This is useful for adding new packages or updating existing ones while preserving the environment.
Syntax
By default,
conda env update uses environment.yml in the current directory and updates the currently active environment.Target Environment Specification
Name of environment to update. If not specified, conda will:
- Use the name from the environment file
- Fall back to the currently active environment (
CONDA_DEFAULT_ENV)
Full path to environment location (i.e. prefix).
File Options
Environment definition file containing the packages to install or update.Supported formats:
- YAML environment files (environment.yml)
- Requirements.txt files
- Any format supported by environment specifier plugins
Update Behavior Options
Remove installed packages not defined in environment.yml. This makes the environment match the specification file exactly.
Environment Specifier Options
Specify which environment specifier plugin to use for parsing the environment file.
Frozen Environment Options
DANGEROUS. Use at your own risk. Ignore protections if the environment is frozen.
Solver Options
Choose which solver backend to use.
Output and Prompt Options
Report all output as JSON. Suitable for using conda programmatically.
Can be used multiple times. Once for INFO, twice for DEBUG, three times for TRACE.
Do not display progress bar.
Examples
Update current environment
environment.yml in the current directory.
Update specific environment
myenv environment with packages from the specified file.
Update with pruning
Update from specific file
Update from requirements.txt
Update with verbose output
Common Use Cases
Adding new dependencies to a project
Adding new dependencies to a project
Update your environment.yml and apply changes:
- Edit environment.yml:
- Update the environment:
Synchronizing environments across team members
Synchronizing environments across team members
Team members can update their environments to match the project specification:
Updating package versions
Updating package versions
Change version constraints in environment.yml:
Adding environment variables
Adding environment variables
Update environment variables without recreating:
Selective updates vs full sync
Selective updates vs full sync
Without With
--prune (additive):--prune (exact match):Update Behavior
Without —prune (Default)
- Packages in the file are installed or updated
- Existing packages not in the file are kept
- Dependencies are resolved and may be updated
python=3.11, numpy=1.24, pandas=1.5, matplotlib=3.7
Environment file:
python=3.11, numpy=1.26, pandas=2.0, matplotlib=3.7 (matplotlib kept)
With —prune
- Packages in the file are installed or updated
- Packages not in the file are removed
- Environment matches the file exactly
python=3.11, numpy=1.24, pandas=1.5, matplotlib=3.7
Environment file:
python=3.11, numpy=1.26, pandas=2.0 (matplotlib removed)
Differences from conda env create
| Feature | conda env create | conda env update |
|---|---|---|
| Target | Creates new environment | Updates existing environment |
| Existing packages | N/A | Preserved by default |
| —prune flag | N/A | Can remove unlisted packages |
| Use case | Initial setup | Ongoing maintenance |
Troubleshooting
Unable to determine environment
Unable to determine environment
Provide an explicit environment name:Or activate the environment first:
Environment is frozen
Environment is frozen
If you get a frozen environment error:
Conflicts after update
Conflicts after update
If packages conflict after update, try:
- Use
--prunefor a clean state:
- Or recreate the environment:
File not found
File not found
Ensure the file exists:
Best Practices
Use Version Control
Keep environment.yml in version control to track changes and coordinate with team members.
Test Before Pruning
Test
conda env update without --prune first to ensure the update works as expected.Document Changes
Add comments to environment.yml explaining why packages are included or version-pinned.
Regular Updates
Periodically update environments to get security patches and bug fixes.
Related Commands
conda env create- Create a new environment from fileconda env export- Export environment to a fileconda update- Update packages in current environmentconda install- Install additional packagesconda env remove- Remove an environment