By default on Windows, conda saves new virtual environments to your C:/Users/<your username>/AppData/Local/conda/conda
. (AppData is hidden by default, but you can see it in File Explorer by checking View > Hidden Items.)
conda environments can get pretty big, so if you're running low on hard disk space and have another drive mounted, you can easily move your environment to a directory on the other drive and create a symbolic link to the new location. This way, conda will look in its regular path for the environment and will find it just fine, despite the actual files having been moved elsewhere.
Let's say we want to move the environments to a separate drive, mounted as D:\
. We'll put everything in D:\<your username>
.
Open up Command Prompt, and then enter:
# First, move all the contents of your environments directory over to the new location:
mv "C:\Users\<your username>\AppData\Local\conda\conda" "D:\<your username>\conda"
# Now make a linke from the location conda looks for to the new directory that you've moved everything to:
mklink /D "C:\Users\<your username>\AppData\Local\conda\conda" "D:\<your username>\conda"
(The \D
flag directs mklink
to make a symlink instead of a hard link.)
And there you go!
Thanks for laying this out.
It's interesting that if I use the package manager from the conda prompt (e.g.
conda install git
) the symlink is replaced by a folder and any package install attempt just fails.