I’m using conda prefix to specify the directory to create my conda environment since my home directory has a small storage quota. But I noticed that conda still creating a .conda directory in my home directory which is quite large.
I’m running the following command.
conda env create -f environment.yml -p path_to_env/conda_env
The .conda dir in my home directory has:
- environments.txt file with the symbolic link to the env create using the prefix.
- pkgs directory with many python packages.
Is there a way to avoid creating the .conda dir in my home directory or make it very small?
Advertisement
Answer
The ~/.conda/environments.txt
is unavoidable. The location of environments and packages is controlled by the envs_dirs
and pkgs_dirs
variables respectively. See docs:
conda config --describe envs_dirs pkgs_dirs # # envs_dirs (sequence: primitive) # # aliases: envs_path # # env var string delimiter: ':' # # The list of directories to search for named environments. When # # creating a new named environment, the environment will be placed in # # the first writable location. # # # envs_dirs: [] # # pkgs_dirs (sequence: primitive) # # env var string delimiter: ',' # # The list of directories where locally-available packages are linked # # from at install time. Packages not locally available are downloaded # # and extracted into the first writable directory. # # # pkgs_dirs: []
Recommendation
Provide a pkgs_dirs
directory that isn’t in under your home directory. Also, since Conda uses hardlinks to conserve disk usage, it is recommended you also provide an envs_dirs
that is on the same volume. This also gives you the advantage that you should no longer need to specify a --prefix,-p
argument to avoid environments being created under the user home, but you can instead use a --name,-n
argument and specify your environments by name.