conda rename command renames an existing conda environment by cloning it to a new location and removing the original.
Syntax
Arguments
DESTINATION
New name for the conda environment.
Can be either:
- A simple name (environment will be created in default envs directory)
- A full path (environment will be created at that location)
Options
-n, --name NAME
Name of the environment to rename.
-p, --prefix PREFIX
Full path to the environment prefix to rename.
-y, --yes
Do not ask for confirmation. If the destination environment already exists, it will be overwritten.
-d, --dry-run
Only display what would have been done without making any changes.
-q, --quiet
Do not display progress bar.
--json
Report all output as JSON.
Restrictions
The following environments cannot be renamed:- Base environment: The root conda environment cannot be renamed
- Currently active environment: You must deactivate an environment before renaming it
- Default activation environment: If an environment is configured as
default_activation_envin your conda configuration, it cannot be renamed
Common Use Cases
Rename environment by name
Rename environment by path
Preview rename operation
See what would happen without making changes:Force rename without confirmation
Rename to specific path
How It Works
Theconda rename command performs the following steps:
-
Validates source environment:
- Ensures the environment exists
- Checks it’s not the base environment
- Checks it’s not currently active
- Checks it’s not the default activation environment
-
Validates destination:
- Ensures destination doesn’t exist (or
--yesis used) - Validates the destination path/name is valid
- Ensures destination doesn’t exist (or
-
Clones the environment:
- Creates a complete copy of the environment at the new location
- Preserves all packages and their versions
-
Removes the original:
- Deletes the original environment directory
The rename operation is atomic when using the
--yes flag, meaning if something goes wrong, the operation is rolled back.Example: Complete Workflow
Error Handling
Base environment error
Active environment error
Destination exists error
--yes to overwrite or choose a different name:
Performance Considerations
- Renaming large environments can take time as it involves cloning all packages
- The operation requires enough disk space to temporarily hold both environments
- Network access is not required (unlike
conda create)
Unlike creating a new environment from scratch, renaming preserves the exact state of the original environment, including all package metadata and history.