Skip to main content

Overview

The conda env remove command removes (deletes) a conda environment and all of its installed packages. This operation is destructive and cannot be undone.
Destructive OperationThis command permanently deletes the environment and all its contents. Make sure to deactivate the environment before removing it.

Syntax

conda env remove [options]

Target Environment Specification

-n, --name
string
Name of environment to remove.
You must specify either -n or -p to identify the environment to remove.
-p, --prefix
string
Full path to environment location (i.e. prefix) to remove.

Protection Options

--override-frozen
boolean
DANGEROUS. Use at your own risk. Ignore protections if the environment is frozen.
Frozen environments are typically protected to prevent accidental deletion. Only use this flag if you’re certain you want to remove a frozen environment.

Output Options

--json
boolean
Report all output as JSON. Suitable for using conda programmatically.
-y, --yes
boolean
Do not ask for confirmation. Automatically answer ‘yes’ to all prompts.
Useful in scripts and automated workflows where interactive prompts should be avoided.
-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.
-d, --dry-run
boolean
Only display what would have been done without actually removing the environment.

Solver Options

--solver
string
Choose which solver backend to use (primarily for consistency with other commands).

Examples

Remove environment by name

conda env remove -n myenv
Removes the environment named myenv from the default envs directory.

Remove environment by path

conda env remove -p /path/to/env
Removes the environment at the specified path.

Remove without confirmation

conda env remove -n myenv -y
Removes the environment without prompting for confirmation.

Remove frozen environment

conda env remove -n myenv --override-frozen
Removes a frozen environment (use with caution).

Dry run to preview

conda env remove -n myenv --dry-run
Shows what would be removed without actually deleting anything.

Remove with verbose output

conda env remove -n myenv -v
Shows detailed information during the removal process.

Remove with JSON output

conda env remove -n myenv --json
Outputs removal status in JSON format for programmatic use.

Common Use Cases

Remove environments you no longer need:
# List all environments first
conda env list

# Remove old ones
conda env remove -n old-project
conda env remove -n test-env
Check environment sizes and remove large unused ones:
# Check sizes
conda env list --size

# Remove large unused environment
conda env remove -n large-env
Remove and recreate an environment with fresh packages:
conda env remove -n myenv
conda env create -f environment.yml
Remove temporary environments in CI/CD pipelines:
#!/bin/bash
# Create temporary test environment
conda create -n test-$BUILD_ID python=3.11 pytest

# Run tests
conda run -n test-$BUILD_ID pytest

# Clean up
conda env remove -n test-$BUILD_ID -y
If an environment becomes corrupted, remove and recreate it:
conda env remove -n corrupted-env -y
conda env create -n corrupted-env -f backup-environment.yml

Safety Checks

Before removing an environment, conda performs several checks:
1

Environment must exist

Conda verifies the environment exists before attempting removal.
2

Environment must be inactive

You cannot remove the currently active environment. Deactivate it first:
conda deactivate
conda env remove -n myenv
3

Frozen environment protection

Frozen environments cannot be removed unless --override-frozen is used.
4

Confirmation prompt

Unless -y is specified, conda will ask for confirmation before deletion.

What Gets Removed

When you remove an environment, conda deletes:
  • All installed packages
  • Python interpreter
  • All conda-managed files
  • Environment-specific configuration files
  • Activation/deactivation scripts
  • Any files in the environment directory
All files are deletedThis includes any files you may have manually added to the environment directory. Back up important files before removing an environment.

Troubleshooting

Deactivate the environment first:
conda deactivate
conda env remove -n myenv
If you have stacked environments, deactivate all of them:
conda deactivate
conda deactivate  # Repeat as needed
conda env remove -n myenv
Verify the environment exists:
conda env list
Use the exact name or full path shown in the list:
conda env remove -n exact-name
# or
conda env remove -p /full/path/shown/in/list
If you get permission errors:
  1. Ensure you have write permissions to the environment directory
  2. Close any programs that might be using files in the environment
  3. On Windows, ensure no processes are running from that environment
If the environment is frozen:
conda env remove -n myenv --override-frozen
Only use this if you’re certain. Frozen environments are protected for a reason.
If removal fails partway through:
  1. Try running the command again
  2. Manually remove the directory:
# Get the path
conda env list
# Remove manually (use with caution)
rm -rf /path/to/env

Best Practices

Export Before Removing

Save environment specifications before removal:
conda env export -n myenv > myenv-backup.yml
conda env remove -n myenv

Verify Before Deleting

Double-check you’re removing the correct environment:
conda env list
conda env remove -n correct-env-name

Use Dry Run First

Preview what will be removed:
conda env remove -n myenv --dry-run

Deactivate First

Always deactivate before removing:
conda deactivate
conda env remove -n myenv

Alternatives to Removal

Before removing an environment, consider these alternatives:

Clean the environment

conda clean -n myenv --all
Removes unused packages and caches without deleting the environment.

Update instead of recreate

conda env update -n myenv -f environment.yml --prune
Updates the environment to match a specification file.

Clone for backup

conda create -n myenv-backup --clone myenv
Create a backup before making destructive changes.

Build docs developers (and LLMs) love