Cannot remove anaconda environment - anaconda

I made a conda environment and now I want to delete it. I deactivated and made sure no processes were using it. I ran conda env remove -n <name of env> and no errors, but in my C:/Users/Username/anaconda3/envs I can still see it. I run conda env remove --name <name of env> --all and nothing happens. I can still conda activate <name of env> - what is happening here? Shall I just manually delete the directory? It looks like most has been removed, but the Scripts dir still remains.

Read the Docs
You could try
conda remove --name <name of env> --all
and check with
conda info --envs
But it's also common practise to just delete the enviroment folder.

Related

How to delete unnamed conda environemt

I am using Anaconda on macOS. Apart from the base environment, I created pip when I am installing libraries available only from that channel.
But I have one called 'anaconda3' which I can see in Navigator
and also see when checking envs in terminal:
% conda info --envs
# conda environments:
#
base * /Users/marek/opt/anaconda3
pip_env /Users/marek/opt/anaconda3/envs/pip_env
/opt/anaconda3
The thing is that it works strangely, it seems to be at the same location as base but does not work as base env. I can switch it and install different libraries etc. But it works strangely and I cannot update any apps (jupyter, spyder) in it so I want to delete but it is not possible as it has no name.
my goal is to remove that anconda3 (/opt/anaconda3 without any name in terminal) environment
It's perfectly fine that your pip_env environment is in the envs subfolder. This is the default location. You can delete in 3 ways:
conda env remove --name pip_env
or
conda remove --all --prefix "/Users/marek/opt/anaconda3/envs/pip_env"
or you simply delete the folder using your shell. Conda environments are self contained.
You can remove nameless environments using prefix:
conda env remove -p /opt/anaconda3

Stuck at Solving Environment on Anaconda

I am running OSX Catalina. After downloading Anaconda, I'm having trouble downloading external packages. I tried in both the GUI and the terminal, but the process keeps getting stuck at "Solving environment".
I understand creating a new environment can be a workaround, but I would rather fix the issue at hand.
Any ideas?
The following steps may work to resolve the issue.
conda config --remove channels conda-forge
conda config --add channels conda-forge
if it doesn't work then try this
conda update conda
if nothing works try seeing this github solution, it worked for many.
use this:
conda config --set channel_priority strict
pay attention that it is channel_priority and not priority_channel
running
conda config --set channel_priority flexible
worked for me
Update, still ran into some issues so I found Mamba, and oh my god my life changed conda is the worst package manager ever
all my issues were solved when I used mamba
# install mamba
conda install -n base conda-forge::mamba
# use mamba
mamba install pandas
Please, check that python is actually listed in environment.yml or conda create -n your_environment --file requirements.txt python=3.7.
Otherwise, conda is traversing all versions of python available.
Check that Python is listed.
for updated conda version over 4.12.0 'Libmamba' with advantages like:
Improve conda’s resolving speeds by 50-80%*
Maximize backwards compatibility so as to not break any current
functionality
Build the plugin infrastructure for others to create custom solvers
are mentioned in Anaconda's official blog post, A Faster Solver for Conda: Libmamba
so for making libmamba your default solver(make sure your conda version is 4.12):
conda install -n base conda-libmamba-solver
and to try it temporarily:conda create -n demo --experimental-solver=libmamba --dry-run install <some package>
It might be taking long because of package version conflicts. My solution was to install some packages using pip instead of conda install.
For example:
pip install tensorflow
Try this in a new environment so it doesn't mess up your existing ones.
conda config --remove channels conda-forge
conda config --set channel_priority flexible
This fixed the problem with the solving environment step. After that I was able to update packages (such as conda and anaconda) and sort out various dependency issues.
I've had this issue running macOS Monterey, with conda taking an age to solve the environment, failing, and causing immense frustration.
My first suggestion would be to install Mamba [1], of which you have two options. If conda does work, but just takes a long time, you can try
conda install mamba -n base -c conda-forge
If conda won't install anything at all, you can try uninstalling anaconda3 using conda install anaconda-clean, then anaconda-clean --yes, then rm -rf anaconda3,rm -rf ~/anaconda3 and rm -rf ~/opt/anaconda3. From there, download the Mambaforge .sh file [1], and run
bash ~/Downloads/Mambaforge-MacOSX-x86_64.sh
Follow the install, and treat mamba exactly how you would treat conda. Then it's simply a matter of selecting your interpreter in your IDE of choice! You'll find that mamba is way faster.
Failing this, you can try using which pip, and then pip install [your package]. I wouldn't advise this one for lots of packages, as you are essentially bypassing the dependancy check, however for small things, it should work fine. Try it, and uninstall it if you get any clashes. Happy fixing!
I had similar problems trying to install external packages such as graph-tools and I solved it by creating a new environment. I know you prefer other options but it's the only thing that worked for me.
I was having the same issue while creating my conda environment using environment.yml file.
conda env create -f environment.yml
My issue was fixed by updating conda and setting channel priority to strict:
conda update conda
conda config --set channel_priority strict
set conda-forge highest priority, remove defaults channel
conda config --add channels bioconda
conda config --add channels conda-forge
conda config --remove channels defaults
conda config --set channel_priority strict
make sure most your package from conda-forge, not defaults.
If it doesn't work, try
conda update --all
conda clean -a //use with caution
The following works for me.
Spin-off on https://github.com/conda/conda/issues/11919
Instead of waiting (maybe hours) to resolve SAT (A well-known NP-Complete problem) environment, it would be helpful for you to install the faster Conda resolver (https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community). Just so you know, the resolver is not installed by default with Anaconda, so you need to install it manually.
sudo conda update -n base conda
sudo conda install -n base conda-libmamba-solver
conda config --set solver libmamba
Rerun conda install
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 \
-c pytorch -c nvidia
I hope you find it useful.
you may also want to check your ~/.conda directory permissions. I installed conda on my MacOS using Homebrew and for some reason this directory had only read/write permissions for root. After changing the permissions and following the instructions from above, everything works smooth and fast now
upgrading conda base package has fixed it.
ref : https://docs.conda.io/projects/conda/en/latest/user-guide/install/rpm-debian.html
Sounds very simple but make sure you're in your environment
conda activate <Your Environment>
i had the same problem when i tried to install packages for my env i tried the conda env update -f environment.yml even doesn't worked (in yml file i have name: tf2 that i point to update my env still doesnt upgraded)
but now which i tried this it worked :d
conda activate tf2
conda env update -n tf2 -f environment.yml --prune
After some reading I found out the .condarc file is not created by default (is stated by the official Anaconda documentation. So what I did is delete de .condarc file and then used the following command
conda config --set channel_priority flexible
And then it got unstuck
Then I tried conda update conda just to test it, and everything worked again.
For other weary travelers: if you find conda taking hours to solve an environment, try install packages one at a time. Works like a miracle.
Another solution that may not have been mentioned is that the dependencies that you may want to install within your conda env are already installed.
Using conda-list within your env you may confirm.
With a package such as tethys platform they did not mentioned this and i was left wondering why my conda install process kept getting stuck at the solving stage. Late into the night bingo checked into my env and sure enough the dependencies where already installed. Now can progress to my next phase.
I faced the same issue for tensorflow and solved it by doing the next:
create new environment conda create -n tf tensorflow
moved to the new environemnt conda activate tf
downloaded my package there.
it worked and solved the issue, I think this happened due to not completing a previous install and got stuck in the middle.
Try installing ANACONDA3 2019-3.
I had similar issues but after installing the above version of anaconda they were all fixed.
Choose one:
Start fresh with a new Anaconda installation. Pay attention during
installation to make sure that your install path is a subfolder of
your home folder, such as /Users/me/anaconda3
Start fresh using the
.sh installer instead of the .pkg installer. This installer makes it
simpler to choose the destination path, and gives you more choice on
how you want your shell to behave.
check out the link for more details
This is another answer for environment failure, but for windows OS
This fixed the hang for me. Although the install went on to fail.
conda config --set priority_channel strict

Remove Environment in Conda

I somehow installed miniconda and miniconda3.
Now conda env list looks like
base /home/miniconda
env1 /home/miniconda/envs/env1
env2 /home/miniconda/envs/env2
/home/miniconda3
/home/miniconda3/envs/env3
* /home/miniconda3/envs/env4
How can I manage conda environments now?
How to remove env4 conda environment
Looks like "env4" is activated.. To deactivate use,
conda deactivate
After that, you can use this command to remove any environment. ENV_NAME=env4
conda env remove --name ENV_NAME
Or simply just go to the path
/home/miniconda3/envs/
and delete 'env4' from there.

deleting conda environment safely?

I'm new to anaconda and conda. I have created an identical environment in two different directories. Is it safe to just delete the env folder or the environment that I no longer need, or do I need to do something in the anaconda prompt to remove the environment thoroughly? I'm not sure if creating an environment in a local folder leaves a trace in the registry or somewhere else in the computer that needs to be removed too?
conda remove --name myenv --all
Another option is
conda env remove --name myenv
Effectively no difference from the accepted answer, but personally I prefer to use conda env commands when operating on whole envs, and reserve conda remove for managing individual packages.
The difference between these and deleting the folder manually is that Conda provides action hooks for when packages are removed, and so allows packages to execute pre-unlink and post-unlink scripts.

Cloning conda "root", if that is the term for your basic initial install

There seem to be other similar questions, but none that seem to be exactly this.
I have created a conda install on a machine. I want to create the exact same install on a 2nd machine. I could export the environment and then create an environment using that exported information. But in all the examples, I'm creating an environment that is a clone of the root. Not a new root that is a clone of the root.
So how to I create a true clone of a conda install? The idea would be
Export the environment of the root on machine 1
conda [something...] > configuration.yml
Install miniconda using Miniconda....sh on machine 2
Recreate the original environment
conda [install all the stuff including enironments] configuration.yml
I can't seem to find any explicit instructions for doing this. The closest I found suggests:
conda env export > environment.yml
conda env update -n root -f environment.yml
However the first command draws an error:
balter#server:/home/.../Applications$ conda env export > environment.yml
CondaEnvException: Conda Env Exception: Unable to determine environment
Please re-run this command with one of the following options:
* Provide an environment name via --name or -n
* Re-run this command inside an activated conda environment.
balter#server:/home/.../Applications$ conda -h
usage: conda [-h] [-V] command ...
conda is a tool for managing and deploying applications, environments and packages.
Options:
...
...
One of the posts I found on the interwebs discusses two points that I'm unclear about:
1) Whether pip installs also carry over, and
2) The difference between
conda env create
and
conda create
Conda environments exist as an easy solution to this sort of problem. However, it is possible to do what you ask.
Step 1: confirm you are in the root environment on the first machine, then export a list of the installed packages:
$ source activate root
$ conda list -e > root.yml
Step 2: on the other machine, download and install Miniconda, then install the packages from root.yml:
$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash Miniconda3-latest-Linux-x86_64.sh
$ conda install --file root.yml

Resources