How to delete conda environments on Mac

Before you delete conda environments on a Mac, save each one’s list of packages: an environment is your setup, and a deleted one can only be built again, not restored. Each holds its own copy of Python and packages, often a few gigabytes, yet conda’s package cache may keep much of that space after you delete it. This guide covers deleting in Terminal or Anaconda Navigator and clearing the package cache.

Export the environment first

A deleted environment can’t be restored, only recreated. This command saves the list of its conda and pip packages to a file in the current folder (replace myenv with its name):

conda env export --name myenv > myenv.yml

Your own scripts and notebooks are not inside an environment unless you saved them in its folder. Later this command builds the same environment again:

conda env create -f myenv.yml

List your environments

This command shows every environment with its folder. The active one is marked with an asterisk:

conda env list

How to delete a conda environment

  1. If the environment is active, leave it:
conda deactivate
  1. Run this command. It deletes the environment with all its packages and removes it from conda’s list:
conda remove --name myenv --all
  1. Check that it’s gone:
conda env list

conda also has env remove with the same --name: it does the same. Don’t delete an environment’s folder in Finder: conda keeps it in its list. For an environment without a name, give its folder in place of <folder>: conda remove --prefix <folder> --all Leave base alone: conda itself lives there.

Delete an environment in Anaconda Navigator

  1. Open Anaconda Navigator and click Environments in the sidebar.
  2. Click the environment you want to delete.
  3. Click Remove at the bottom of the environments list.
  4. Confirm with Remove.

Clear the package cache with conda clean

conda keeps downloaded packages in its own cache, so deleting an environment frees less than you might expect. This command deletes the index cache, packages no environment uses, downloaded archives, temporary files and logs. Environments stay. Add --dry-run to see first what it would delete:

conda clean --all

To remove Anaconda itself, see how to uninstall Anaconda.

Keep your Mac tidy

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned

MacWashing doesn’t delete conda environments: each one is your own setup, and conda knows what is inside. System Junk clears the caches of your other apps and developer tools.

Free trial · macOS 14 or later

Questions and answers

Can I recover a deleted conda environment?

Only by building it again from an exported file: conda env create -f myenv.yml That is why exporting first matters.

Why didn’t deleting a conda environment free much space?

Its packages may stay in conda’s package cache. This deletes the packages no environment uses: conda clean --all

Can I delete a conda environment folder in Finder?

Better not: conda would still list it. Use this command: conda remove --name myenv --all For an environment without a name, give its folder with --prefix instead.