How to Remove Conda Env in Python? 2 Step-by-Step Methods

Sharing is Caring

This article is based on how to remove Conda Env in Python. We will guide you through the basics of working with conda interface in simple and easy-to-follow steps. Conda is a free or open-source application or package management system for Python programming. It is a very good alternative to pip as it offers package and interface management in a single utility. Using conda, you can create, activate, deactivate, switch, and delete virtual environments with simple and intuitive keys.

How to Remove Conda Env in Python?

Deleting an Installed Conda interface Environment from your article. You can remove any environment that is installed in your python programming in the Environment Explorer tab. You can also create new interfaces or environments from within python programming (Conda tab, home screen, and then click the plus sign). And you can create a python programming in any environment you want. Select the “Files” tab on the first screen and click the “New” dropdown menu, and in that menu select a Python environment from the list. Simply deactivate it and rid your application of its artifacts by recursively removing it. The best way to uninstall it completely is by running: 

  • $ pip install
  • pip-autoremove
  • $ pip-autoremove jupyter -y

Conda Create Environment

Conda creates an environment to create a virtual interface environment with conda, all you need is access to a terminal on a system with conda installed.

conda create –name {env_name}
conda create –name mlenv

Create an environment + specific python version
conda create –name {env_name} {python==3.7.5}
conda create –name mlenv python==3.7.5

Create an environment + specific Python version + packages
conda create –name env_name python==3.7.5 package_name1 package_name2
conda create –name mlenv python==3.7.5 pandas numpy

Activate the environment

Activate the conda environment
conda activate {env_name}
conda deactivate

Install more packages

Once activated you can install more packages using either conda or with pip.

With Conda
conda install pkg_name1==1.x.y pkg_name2==1.x.y

With pip
pip install pkg_name2==1.x.y pkg_name2==1.x.y
or install multiple packages from requirements.txt.
pip install -r requirements.txt

See the list of packages and environments

conda list
conda list -n myenv
conda env list
# or
conda info –envs
# conda environments:
C:\Users\selva\.julia\conda\3
base * C:\Users\selva\AppData\Local\Continuum\anaconda3
envmnt C:\Users\selva\AppData\Local\Continuum\anaconda3\envs\envmnt
juliaenv C:\Users\selva\AppData\Local\Continuum\anaconda3\envs\juliaenv
mlcourse C:\Users\selva\AppData\Local\Continuum\anaconda3\envs\mlcourse 

Remove Conda Env (Environment)

conda env remove -n env_name
conda info –envs
conda env list
conda env remove -n ENV_NAME
conda create –name myclone –clone myenv
conda create -n myenv python=3.6
conda remove –name myenv –all
conda env list

How To Remove Conda Env (Environment)?

Deactivation

The first step to do is to disable the environment in Python by entering the following command.
conda env remove -n env_name
conda info –envs
conda env list
conda env remove -n ENV_NAME
conda create –name myclone –clone myenv
conda create -n myenv python=3.6
conda remove –name myenv –all
conda env list

Removal of Env

To remove the Conda environment type the following command.
conda env remove -n

Making Sure

To make sure the environment is deleted type the following command.
conda info –envs or conda env list

Build an identical environment.

conda list –explicit > spec-file.txt
conda create –name myenv –file spec-file.txt
conda install –name env_name –file spec-file.txt

Sharing environments across platforms (a better way)

conda install python=3.7 pkg_name1 pkg_name2 pkg_name3
conda env export –from-history > environment.yml
conda env create -f environment.yml

Rollback/ Restore to an earlier version of an environment

conda list –revisions
conda install –rev 3

Conclusion

In final words, you should step by step method so that there won’t be any issue regarding the removal of env.

Also Read: Python Sorting List – Alphabetically, Numbers, Tuples, Objects

FAQ

How to remove conda environment?

1. First deactivate the environment.
2. conda env remove -n <name of environment>
3. To make sure you have deleted it, you can use this code.
 conda info –envs or conda env list.

Leave a Comment