Mircea
Mircea

Reputation: 1999

How to move .conda from one folder to another at the moment of creating the environment

I have to connect to a server where my user has access to one small partition from /home/users/user_name where I have a quota of limited space and a bigger partition into /big_partition/users/user

After I am logging into that server I will arrive at /home/users/user_name at the bigging. After that, I am doing the following steps.

  1. cd /big_partition/users/user
  2. create conda --prefix=envs python=3.6

on the 4th line, it says Package plan for installation in environment /big_partition/users/user/envs: which is ok.

  1. press y, and not I am getting the following message.

    OSError: [Errno 122] Disk quota exceeded: '/home/users/user_name/.conda/envs/.pkgs/python-3.6.2-0/lib/python3.6/unittest/result.py'

Can anyone help me to understand how can I move the .conda folder from /home/users/user_name to /big_partition/users/user at the moment when I am creating this environment?

Upvotes: 13

Views: 33344

Answers (2)

merv
merv

Reputation: 77090

Configure Environment and Package Default Locations

I'd guess that, despite your efforts to put your environments on the large partition, there is still a default user-level package cache and that is filling up the home partition. At minimum, set up a new package cache and a default environments directory on the large partition:

# create a new pkgs_dirs (wherever, doesn't have to be hidden)
mkdir -p /big_partition/users/user/.conda/pkgs

# add it to Conda as your default
conda config --add pkgs_dirs /big_partition/users/user/.conda/pkgs

# create a new envs_dirs (again wherever)
mkdir -p /big_partition/users/user/.conda/envs

# add it to Conda as your default
conda config --add envs_dirs /big_partition/users/user/.conda/envs

Now you don't have to fuss around with using the --prefix flag any more - your named environments (conda create -n foo) will by default be created inside this directory and you can activate by name instead of directory (conda activate foo).

Transferring Previous Environments and Package Cache

Unfortunately, there's not a great way to move Conda environments across filesystems without destroying the hardlinks. Instead, you'll need to recreate your environments. Since you may or may not want to bother with this, I'm only going to outline it. I can elaborate if needed.

  1. Archive environments. Use conda env export -n foo > foo.yaml (One per environment.)
  2. Move package cache. Copy contents of old package cache (/home/users/user_name/.conda/envs/.pkgs/) to new package cache.
  3. Recreate environments. Use conda env create -n foo -f foo.yaml.

Again, you could just skip this altogether. This is mainly if you want to be very thorough about transferring and not having to redownload stuff for environments you already created.

After this you can delete some the stuff under the old ~/.conda/envs/pkgs folder.

Upvotes: 34

Mircea
Mircea

Reputation: 1999

I found the solution. All I need to do is to export CONDA_ENVS_PATH with the path where I want to be the .conda

export CONDA_ENVS_PATH=.

Upvotes: 2

Related Questions