I have created two environments(env1 and env2) in the following path:
Users/user/conda/envs
I want to remove env1 and have tried every combination of the following commands but it is not removing:
conda remove --name env1
conda remove --name conda/envs/env1
Thanks in advance for your help!
You can use the following command lines in terminal (permissions may be required):
conda env remove --name myenv
alternatively:
conda remove --name myenv --all
You can do conda info --envs to verify the action was successful.
More info here.
Some misunderstanding here - I think you were trying to replace --name with your environment name which will not work, while you have to replace myenv with your environment name.
It seems that the documentation is not that clear. If the environment has not any package installed the command conda remove --name myenv --all won't work. In that case it's necessary to use conda env remove --name myenv. The issue is commented on here
I tried a lot of things too and then found "conda-env" was the key.
conda-env remove -n myenv
For those who can't find a name or have the same name env for every environment they've created then you need to execute this command to remove the conda env from specific directory
conda remove --prefix /path/to/conda-env/ --all
Related
I want to remove a certain environment created with conda. How can I achieve that? Let's say I have an active testenv environment. I tried, by following documentation, with:
$ conda env remove
CondaEnvironmentError: cannot remove current environment. deactivate and run conda remove again
I then deactivate it:
$ source deactivate
I try running again the command to remove it and I still get the same error. What is going wrong here?
You probably didn't fully deactivate the Conda environment - remember, the command you need to use with Conda is conda deactivate (for older versions, use source deactivate). So it may be wise to start a new shell and activate the environment in that before you try. Then deactivate it.
You can use the command
conda env remove -n ENV_NAME
to remove the environment with that name. (--name is equivalent to -n)
Note that you can also place environments anywhere you want using -p /path/to/env instead of -n ENV_NAME when both creating and deleting environments, if you choose. They don't have to live in your conda installation.
UPDATE, 30 Jan 2019: From Conda 4.6 onwards the conda activate command becomes the new official way to activate an environment across all platforms. The changes are described in this Anaconda blog post
After making sure your environment is not active, type:
$ conda env remove --name ENVIRONMENT
Official documentation way worked for me:
conda remove --name myenv --all
Or just conda env remove --name myenv.
To verify that the environment was removed, in your terminal window or an Anaconda Prompt, run:
conda info --envs
The environments list that displays should not show the removed environment.
You anaconda3 enviroments folder might list an empty folder of deleted environment in your anaconda3 installation folder, like:
/opt/anaconda3/envs
If you are in base:
(base) HP-Compaq-Elite-8300-CMT:~$
remove env_name by:
conda env remove -n env_name
if you are already in env_name environment :
(env_name) HP-Compaq-Elite-8300-CMT:~$
deactivate then remove by :
conda deactivate
conda env remove -n env_name
In my windows 10 Enterprise edition os this code works fine:
(suppose for environment namely testenv)
conda env remove --name testenv
Environments created with the --prefix or -p flag must be removed with the -p flag (not -n).
For example:
conda remove -p </filepath/myenvironment> --all, in which </filepath/myenvironment> is substituted with a complete or relative path to the environment.
There're 3 ways to achieve this in total. Assuming you have a environment named myenv,
conda env remove --name myenv, -n is shortcut for --name.
conda remove --name myenv --all.
Delete the env folder directly. (Not recommended)
# list environments and their locations
conda env list
# or
# conda info --envs
# delete the folder listed
rm -rf /Users/username/.local/share/conda/envs/myenv
If you wanna delete the environment without a prompt to let you check again. Use -y, shortcut for --yes. (For global use check silent prompt in conda)
conda env remove -n myenv -y
conda remove -n myenv --all -y
References
conda env --help
conda remove --help
First deactivate the environment that you wish to remove.
Then type the following code:
conda env remove -n <your environment name>
To make sure you have deleted it, you can use the following code.
conda info --envs or conda env list
4.If you wan to remove all the dependencies along with the installed packages, you can use:
conda remove -n <environment name> --all
You may try the following: Open anaconda command prompt and type
conda remove --name myenv --all
This will remove the entire environment.
Further reading: docs.conda.io > Manage Environments
To remove complete conda environment :
conda remove --name YOUR_CONDA_ENV_NAME --all
First you have to deactivate your environment before removing it. You can remove conda environment by using the following command
Suppose your environment name is "sample_env" , you can remove this environment by using
source deactivate
conda remove -n sample_env --all
'--all' will be used to remove all the dependencies
My environment name is: test
conda remove -n test --all
Use source deactivate to deactivate the environment before removing it, replace ENV_NAME with the environment you wish to remove:
source deactivate
conda env remove -n ENV_NAME
First I checkout from the environment (tensorflow):
conda deactivate
Then I removed the environment by:
conda remove -n tensorflow --all
The tensorflow is the name of my environment
You can check your env name using this command:
conda env list
First deactivate the environment and come back to the base environment. From the base, you should be able to run the command conda env remove -n <envname>. This will give you the message
Remove all packages in environment
C:\Users\<username>\AppData\Local\Continuum\anaconda3\envs\{envname}:
This worked for me:
conda env remove --name tensorflow
if you are unfamiliar with the command line , you can remove it using the anaconda dashboard
View the environments in Anaconda or miniconda:
conda env list
If you have created an environment using name then use:
conda remove -n envname --all
if you have created an environment using prefix then use:
conda remove -p [path] --all
Change the envname with your environment name and in case of prefix provide the complete path of the environment eg: C:/Users/techv/Desktop/project/env.
--all will remove all the dependencies of the target environment.
I hope this answer will be helpful.
Because you can only deactivate the active environment, so conda deactivate does not need nor accept arguments. The error message is very explicit here.
Just call conda deactivate
https://github.com/conda/conda/issues/7296#issuecomment-389504269
on terminal it's showing
(base) [root#localhost ~]#
simply hit command : conda deactivate
and you are out of conda env , now your prompt will look like
[root#localhost ~]#
I create a virtual environment with conda
$ conda create test_env numpy .....
It gets created successfully.
$ conda env list
# conda environments:
#
base * /home/myname/anaconda3
my_project_env /home/myname/anaconda3/envs/my_project_env
test_env /home/myname/anaconda3/envs/test_env
but I can not activate it
$ source activate my_project_env
returns - activate: No such file or directory
The only place I find activate is within the whole anaconda3 is in /common folder
source anaconda3/envs/my_project_env/lib/python3.6/venv/scripts/common/activate my_project_env
When I run it with this path I get VENV_PROMPT "kind of environment" but when I check libraries with pip list it returns a global list of installed libraries instead of the selected few.
$ source anaconda3/envs/my_project_env/lib/python3.6/venv/scripts/common/activate my_project_env
__VENV_PROMPT__myname#box:~$ pip3 list
I met with the same problem. It is because I have changed the system's $PATH variable from anaconda's main bin directory to the environment's bin directory. Actually, the activate's path is under /home/users/anaconda3/bin/. So I just use the following command to make a link between the two bin directories:
ln -s /home/userName/anaconda3/bin/activate /home/userName/anaconda3/envs/envName/bin/activate
ln -s /home/userName/anaconda3/bin/deactivate /home/userName/anaconda3/envs/envName/bin/deactivate
Try to use this command activate your conda environment:
source activate /home/myname/anaconda3/envs/my_project_env
Recommended command to create environment with python version 2.7 :
conda create -n my_project_env python=2.7
Check your conda version
conda -V
Create virtual environment for your project
conda create -n yourenvname python=x.x anaconda
To activate your virtual environment
source activate yourenvname
As others have mentioned, it may be a PATH issue. However, if you're still able to run other conda commands then you may need to either conda update conda or delete conda and reinstall. In my case, I was running miniconda which I believe simply did not contain the activate binary.
Running conda activate instead of source activate solved my issues.
I installed anaconda in C:\Program Files\Anaconda3. Every time to create a new env, I just do cmd and write:
conda create --name envname python=3.5
But how can i install a new env from the "environments.yml" file
conda env create allows an option --file for an environment file:
conda env create --name envname --file=environments.yml
The above answers did not work for me with conda 4.7.12, but this (from the Anaconda documentation) did:
conda env create -f environment.yml
conda env create --file environment.yml
To sum up (as of conda 4.8.4) conda env create and conda create are two fundamentally different commands.
conda create
this is the official (quasi-recommended) command to create envs, listed in the general commands section of the docs
conda create --file expects a requirements.txt, not an environment.yml, each line in the given file is treated as a package-reference
conda env create
instead, this command is needed to create an environment from a given environment.yml
environment.yml files have a specific syntax (e.g. for env name, source channels, packages)
e.g. conda env create --file environment.yml
some flags available with conda create are not available with conda env create, such as --strict-channel-priority, which may result in some confusion
conda env create is only mentioned deep into the docs of conda (although I think it is the more common command to use)
Worked for me on anaconda, mini conda Replace the .yml file path to location of environment.yml file.
conda env create --prefix ./env -f ../yml file path/environment.yml
How can a pre-existing conda environment be updated with another .yml file. This is extremely helpful when working on projects that have multiple requirement files, i.e. base.yml, local.yml, production.yml, etc.
For example, below is a base.yml file has conda-forge, conda, and pip packages:
base.yml
name: myenv
channels:
- conda-forge
dependencies:
- django=1.10.5
- pip:
- django-crispy-forms==1.6.1
The actual environment is created with:
conda env create -f base.yml.
Later on, additional packages need to be added to base.yml. Another file, say local.yml, needs to import those updates.
Previous attempts to accomplish this include:
creating a local.yml file with an import definition:
channels:
dependencies:
- pip:
- boto3==1.4.4
imports:
- requirements/base.
And then run the command:
conda install -f local.yml.
This does not work. Any thoughts?
Try using conda env update:
conda activate myenv
conda env update --file local.yml --prune
--prune uninstalls dependencies which were removed from local.yml, as pointed out in this answer by #Blink.
Or without the need to activate the environment (thanks #NumesSanguis):
conda env update --name myenv --file local.yml --prune
See Updating an environment in Conda User Guide.
The suggested answer is partially correct. You'll need to add the --prune option to also uninstall packages that were removed from the environment.yml.
Correct command:
conda env update -f local.yml --prune
alkamid's answer is on the right lines, but I have found that Conda fails to install new dependencies if the environment is already active. Deactivating the environment first resolves this:
source deactivate;
conda env update -f whatever.yml;
source activate my_environment_name; # Must be AFTER the conda env update line!
I can create a new conda environment, with program biopython with this:
conda create --name snowflakes biopython
What if I do not want to install any program? It seems I can not do that:
ยป conda create --name tryout
Error: too few arguments, must supply command line package specs or --file
You can specify one or more default packages to install when creating
an environment. Doing so allows you to call conda create without
explicitly providing any package names.
To set the provided packages, call conda config like this:
conda config --add create_default_packages PACKAGE_NAME
You can give a package name of just "python" to get a base, empty install.
conda create --name myenv python
conda create --name myenv python=3.4
If you've created a create_default_packages block in your .condarc file, #joelion's answer will install those packages. If you don't want those, use the --no-default-packages flag. For example:
conda create --name myenv python --no-default-packages
This is how to create a truly empty (light) conda_env with 0 packages:
conda create --name myenv --no-default-packages
it will take a few seconds to create and finish.
To create an environment that is absolutely empty, without python and/or any other default package, just make a new folder in envs directory in your Anaconda installation (Anaconda3 in this example):.
~\Anaconda3\envs>mkdir empy_env
The first time that you activate this environment a directory named Scripts in Windows, bin in Linux, with a few batch files are created. At the time of this post this works for Anaconda version 4.3.30 both in Windows and Linux.
I have noticed that #cel has suggested the same thing in the first comment under the question, but obviously it hasn't got the attention it deserves!
For Conda 2020.11 Linux, the following command will create an empty environment.
conda create --name your-env-name