How to Delete a Conda Environment
Published on
Updated on
A conda environment is an isolated folder of packages and a specific Python version. Deleting one removes that folder and everything in it, freeing disk space and clearing a broken or unused setup — it does not touch your other environments or your base install.
Quick answer
To delete a conda environment, deactivate it first (you cannot remove the active one), then run either command:
conda deactivate
conda env remove --name myenvconda remove --name myenv --all does the same thing — removing every package equals removing the environment:
conda remove --name myenv --all| Goal | Command |
|---|---|
| Delete by name | conda env remove --name myenv |
| Delete by name (equivalent) | conda remove --name myenv --all |
| Delete by path | conda env remove --prefix /path/to/env |
| Deactivate first | conda deactivate |
| List environments | conda env list |
--namehas the short form-n, and--prefixhas the short form-p. Soconda env remove -n myenvis identical toconda env remove --name myenv.
Delete a conda environment by name
This is the standard case. Replace myenv with your environment name:
conda env remove --name myenvIf the environment is currently active, conda refuses to delete it. Run conda deactivate to return to base first, then remove it. To confirm the name before deleting, list everything:
conda env listThe active environment is marked with an asterisk (*).
Delete a conda environment by path
Environments created with --prefix (a custom location instead of the default envs/ folder) are deleted by path, not name:
conda env remove --prefix /path/to/envDelete a corrupted environment
If conda env remove fails — a common symptom of a half-installed or corrupted environment — delete the folder directly. Find the location with conda env list, then remove the directory:
# macOS / Linux
rm -rf /path/to/anaconda3/envs/myenv
# Windows (PowerShell)
Remove-Item -Recurse -Force C:\Users\you\anaconda3\envs\myenvAfter a manual delete, clean conda's cache so the environment no longer shows up:
conda clean --allRelated tasks
Rename an environment
Conda has no direct rename. Clone to the new name, then delete the old one:
conda create --name newenv --clone oldenv
conda env remove --name oldenvRemove a single package (not the whole environment)
conda remove --name myenv package_nameRecover a deleted environment
You cannot. conda env remove deletes the folder permanently. Recreate it from an environment.yml if you exported one beforehand:
conda env export > environment.yml # before deleting
conda env create -f environment.yml # to restore laterFAQ
What is the command to delete a conda environment?
conda env remove --name myenv, or the equivalent conda remove --name myenv --all. Deactivate the environment first if it is active.
Why can't I delete my conda environment?
You are probably still inside it. Conda will not remove the active environment. Run conda deactivate to return to base, then remove it. If removal still fails, the environment may be corrupted — delete its folder directly and run conda clean --all.
How do I delete a conda environment by path?
Use conda env remove --prefix /path/to/env for environments created in a custom location with --prefix.
Does deleting an environment affect other environments?
No. Each conda environment is an isolated folder. Removing one leaves your other environments and the base installation untouched.
Related Guides
- How to Create a Conda Environment
- How to Run Python Scripts
- Managing conda environments (official docs) (opens in a new tab)