LandA
LandA

Reputation: 51

conda env remove -n envname does not delete the actual folder?

I have a question regarding conda environments. Whenever I try to remove an environment in command prompt with conda env remove -n envname, the actual folder remains in the environments folder. Thus, if I try to recreate the environment with the same name, command prompt gives me an error saying that a folder already exists there and whether or not I would like to proceed.

$ conda create --name test
WARNING: A directory already exists at the target location 'C:\...\Anaconda3\envs\test' 
but it is not a conda environment.
Continue creating environment (y/[n])?

I'm not sure whether that is safe, so at this point I manually delete the folder. Is this something that is viable? Is leaving the folder there normal conda behavior? Is there a solution to allow conda to just automatically delete the folder?

Thanks so much!

Upvotes: 5

Views: 5569

Answers (1)

CheapSquier
CheapSquier

Reputation: 437

Ok, I think I figured out the issue. Before you try to remove the env, make sure that:

  1. The env isn't still attached to any running processes. For example, if you'd used it in VS Code, make sure you close VS Code (that might assume you're using the Anaconda Extension pack, not sure, haven't tried without it).
  2. Make sure you use conda deactivate to deactivate the env you're about to remove.

If the env (or maybe more correctly, the folders where it was stored) are still referenced by a running process or you haven't deactivated the env, conda env remove will act like it's removing the env and it won't show up in conda env list, but it will still be possible to activate it and the folders will remain.

Upvotes: 3

Related Questions