×

Search anything:

Delete Conda Environment (7 commands)

Binary Tree book by OpenGenus

Open-Source Internship opportunity by OpenGenus for programmers. Apply now.

In this article, we have explained and presented 7 commands to delete a Conda environment permanently. We can delete a conda environment either by name or by path.

Table of contents:

  1. Step 1: Find the Conda environment to delete
  2. Step 2: Get out of the environment
  3. Step 3: Delete the Conda Environment (6 commands)
  4. Delete Directory directly?
  5. Why to delete a Conda environment?

Step 1: Find the Conda environment to delete

To find the name of the environment you want to delete, we can get the list of all Conda environments as follows:

conda env list

Let the name of the environment to be delete is corrupted_env.

Step 2: Get out of the environment

You cannot delete the conda environment you are within. To get out of the current environment, use the command:

conda deactivate

Step 3: Delete the Conda Environment (6 commands)

If the name of the environment to be delete is corrupted_env, then use the following command to delete it:

conda env remove -n corrupted_env

OR

conda env remove --name corrupted_env

Alternatively, we can use the following command:

conda remove --name corrupted_env --all

OR

conda remove -n corrupted_env --all

If you have the path where a conda environment is located, you can directly specify the path instead of name of the conda environment. In this case, the command will be:

conda env remove -p /path/to/env

OR

conda env remove --prefix /path/to/env

Delete Directory directly?

It is not advised to delete the directory directly where the conda environment is stored. In some cases, it might be necessary so the steps are:

  • Find the path of the conda environment using:
conda info --envs
  • Delete the directory directly:
rm -rf /Users/username/.local/share/conda/envs/corrupted_env

Why to delete a Conda environment?

You may need to delete a conda environment for the following reasons:

  • To free space: Conda environments consume space and you may eventually, run out of space on your system. To free space, you can delete conda environments you do not want.
  • Delete a corrupted environment: Conda environments get corrupted easily and it is often, easier to start from scratch by creating a new environment. In this case, you will want to delete the corrupted conda environment to stay safe.
  • Good practice: It is a good practice to delete the conda environments you do not need.

With this article at OpenGenus, you must have the complete idea of how to delete a conda environment.

Ue Kiao, PhD

Ue Kiao, PhD

Ue Kiao is a Technical Author and Software Developer with B. Sc in Computer Science at National Taiwan University and PhD in Algorithms at Tokyo Institute of Technology | Researcher at TaoBao

Read More

Improved & Reviewed by:


OpenGenus Tech Review Team OpenGenus Tech Review Team
Delete Conda Environment (7 commands)
Share this