Asking for those of us who have been using python and conda for a long time, and installed a bunch of packages in the base environment when we were first learning, and now want to clean things up to to have an empty base environment with maybe nothing more than numpy and matplotlib.
The ideal solution would in effect completely wipe the base environment but preserve other environments.
A few solutions mention conda install --revision 0
, however when I look at my past revisions using conda list --revisions
, I see a ton of packages listed. And I can confirm using conda list
that at least a few of these packages were installed using default conda channels and have not been updated since revision 0.
I also wrote a bash script (which I have since lost) that went through and uninstalled each package. But this was rather unwieldy.
Any other recommendations to achieve a blank base environment?
One approach is to use the conda env update
command with the --prune
flag. That is, specifically use a minimal YAML:
conda-base.yaml
dependencies:
- conda
- python=3.10 # specify the version you want
and run (with base activated!):
conda activate base
conda env update -f conda-base.yaml --prune -v
Hypothetically, that should remove everything but what is required to run conda
. However, in practice I see weird stuff when used on an Anaconda base. Specifically, I see BLAS and some Python libraries (NumPy, SciPy) sticking around for no apparent reason. But it should dump mostly everything unnecessary.
I had unreliable behavior using -n base
(without having base activated), hence why I recommend working from an activated base. Personally, I also include Conda development tooling (anaconda-client
, conda-build
, conda-smithy
, etc), which gave me some issues with Python above v3.10, which is why I leave that as the recommendation in the base. In practice one shouldn't be running your own code in the base interpreter anyway, so hopefully that helps suppress the urge to aggressively upgrade Python in base.