10

I had installed Anaconda on my system before I knew the difference between Anaconda and Miniconda. I would like to downsize to Miniconda since I don't want the bloat of Anaconda, but I already have a handful of environments set up.

So far the only way I can think of migrating is to completely get rid of everything right now, install Miniconda, and then recreate my environments by hand, but that seems quite arduous. Is there a smarter way of going about this?

davzaman
  • 823
  • 2
  • 10
  • 20
  • 2
    `conda env export`, save the .yml files, and `conda env create`. – darthbith May 09 '19 at 02:40
  • Have you tried using `conda remove` to delete unwanted packages from your `base` environment? I've never done this but I don't see why it wouldn't work. Check the docs with `conda remove -h` first. – nekomatic May 09 '19 at 12:08

1 Answers1

8

I agree with @darthbith: Export the envs to YAML files (conda env export) then recreate them once you have Miniconda installed (conda env create).

While there are some experimental tools for packaging and moving envs (i.e., so you avoid having to redownload packages), they only work on a single env basis. So, I can't see how going this route one could avoid making multiple copies of many of the shared files. Instead, if you let Conda handle the environment (re)creation, it will leverage hardlinks to minimize disk usage, and that seems to be one of your aims.

It may be possible to avoid redownloading packages during the environment recreations by retaining the pkgs directory in the root of your Anaconda install, then copying its contents over into the pkgs of the Miniconda install. I would only copy folders/tarballs that don't conflict with the ones that come with Miniconda. After finishing environment recreation, then a conda clean -p would likely be in order, since Anaconda includes many packages that likely aren't getting reused.

merv
  • 67,214
  • 13
  • 180
  • 245
  • This is exactly what I needed, thanks! Just moved over and it was really quick and easy. EDIT: How does it leverage hardlinks to minimize disk usage? It seems to be taking up a ton of space anyway. – davzaman May 09 '19 at 19:31
  • @davzaman I tried to answer this [in another answer](https://stackoverflow.com/a/55602940/570918). – merv May 09 '19 at 19:58
  • 2
    thanks @merv! To future people on this post: if you use Jupyter Lab and use envs as kernels, for some reason it fails to correct the path to the kernel (keeps anaconda3). Go to `~/Library/Jupyter/kernels/env/kernel.json` and change the path there to `miniconda3` for all your envs. – davzaman May 10 '19 at 23:12