What are conda environments, and can you delete them?

Each folder in ~/miniconda3/envs or ~/anaconda3/envs is a Conda environment with its own Python and packages, so remove unused ones with conda env remove rather than by hand.

Shiva ChandraMaker of Clean House · · 2 min read
Short answer

Conda environments are folders under ~/miniconda3/envs or ~/anaconda3/envs, each with its own Python and packages. Look first. An environment is safe to remove if no project uses it. Run conda env remove -n NAME rather than deleting the folder, and export the package list first if you may need it again.

Path
~/miniconda3/envs and ~/anaconda3/envs
What it is
Isolated Python (and other) environments created with conda
Typical size
Often 1 to 5 gigabytes per environment; machine-learning ones are larger
Made by
Conda (Miniconda or Anaconda)
Safe to delete?
Look first
Comes back?
Rebuildable only if you exported its package list; otherwise you have to remember what was installed

What is in this folder?

Every conda create makes a full environment folder. Packages are hard-linked from a shared pkgs cache where possible, but environments with big libraries such as PyTorch still take gigabytes. The base environment is the install itself and should not be removed.

Run conda env list to see all environments and where they are.

Is it safe to delete?

Often, but not automatically. An environment you made for a finished experiment is fine to remove. One you built by hand over weeks may be hard to reproduce if you did not record what you installed. That is why this is Look first, not Safe to clear.

The shared package cache in pkgs is a different story: conda clean --all clears unused cached packages safely.

How do I clear it by hand?

  1. Deactivate the environment you want to remove.
  2. Save its package list if you might want it back.
  3. Remove it by name.
conda env list
conda deactivate
conda env export -n NAME > NAME.yml
conda env remove -n NAME
conda clean --all
Do not remove base, and do not delete an environment folder while a notebook or script is using it.

How do I stop it growing?

Use fewer, shared environments, remove ones when a project finishes, and run conda clean --all to drop unused cached packages.

How Clean House handles it

Clean House recognizes Conda environments, rates them Look first, and shows which project folder or notebook they may belong to when it can tell. It also lists the Conda pkgs cache of downloaded package archives separately, as something that downloads again.

Questions

Is it safe to delete a conda environment?

If no project needs it, yes. Use conda env remove -n NAME, and export the package list first if you may want it back.

Where are conda environments stored on Mac?

Under ~/miniconda3/envs or ~/anaconda3/envs. conda env list shows all of them.

What does conda clean --all do?

It removes unused cached packages and index files, which are downloaded again when needed.

Sources

  1. Conda Docs: conda env remove
  2. Conda Docs: Managing environments