Error when updating conda packages: RemoveError: 'setuptools' is a dependency of conda

Solution 1:

I think this issue in github may be related. This response mentions doing an update of conda using the force flag, which seemed to also work for users who reported that a normal update without the flag didn't work:

conda update --force conda

Solution 2:

I'm not sure why the above answer had negative rating.

I had conda running for some time ... tonight I updated, and then resulted in every conda action resulting in:

RemoveError: 'setuptools' is a dependency of conda and cannot be removed from
conda's operating environment.

The only thing that actually worked was

conda install -c anaconda setuptools

After which sanity was restored. In between correction attempts I tried to create a new environment which always failed with the same error. After the fix above, I found that the desired environment did not exist in 'conda env list' but it refused to create it giving an error that it already existed. I needed to go into my ~/miniconda3/envs directory where I found the offending directory, deleted it, and was able to create a desired.

Solution 3:

setuptools is not installed by conda but pip, so you need to uninstall setuptools by pip

pip uninstall setuptools

and reinstall it though conda:

conda install setuptools