Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conda: Choose where packages are downloaded

I don't have enough space in my default conda directory so I want conda packages to be downloaded at a different location. I have a conda environment created and activated at

/different_drive/condaenv 

Based on what I found online, I tried editing the .condarc file to have

pkgs_dirs
 - /different_drive/pkgs

and edited the permission of the default directory

/home/user/conda/pkgs/

to read-only. However, I just get permission denied errors as conda still tries to download the files to the default directory. Any suggestions on what I can do to change the download location of the packages?

like image 451
CSforStructuralEngineer Avatar asked Nov 15 '18 01:11

CSforStructuralEngineer


People also ask

Where does conda install its packages?

Conda installs packages into the anaconda/pkgs directory. If conda cannot find the file, try using an absolute path name instead of a relative path name. Installing packages directly from the file does not resolve dependencies.

Can I choose where my conda environment is stored?

When you specify an environment directory this is where conda will create the actual environment subdirectories. So what ever you specify as the base envs_dirs it will make a directory in that for each environment you create.

How do I install a Conda package?

Installing with conda. To install conda packages, in the terminal or an Anaconda Prompt, run: conda install [packagename] During the install process, files are extracted into the specified environment, defaulting to the current environment if none is specified. Installing the files of a conda package into an environment can be thought ...

Where are Anaconda packages installed on Linux?

Linux: /home/ /anaconda3. Where Are Conda Packages Installed? Installing packages through Conda requires you to install them into the anaconda/pkgs directory at once.The best way to help Conda find a file is to use an absolute path title rather than the relative path.Packages cannot be installed directly from the file due to dependencies.

What if a package is not available from Conda or anaconda?

If a package is not available from conda or Anaconda.org, you may be able to find and install the package via conda-forge or with another package manager like pip. Pip packages do not have all the features of conda packages and we recommend first trying to install any package with conda.

What is a Conda package in Python?

A conda package is a compressed tarball file (.tar.bz2) or .conda file that contains: system-level libraries. Python or other modules.


2 Answers

The steps provided at the official conda documentation link, answers the question.

After creating the environment, activate it, then install your packages. The packages shall be installed within this environment and not the default location.

Update

Reproducing the commands below for quick reference:

Following command will create a new environment in a subdirectory of the current working directory called demo

conda create --prefix ./demo python=3.6 scipy=0.15.0

Now, activate the environment as follows:

conda activate ./demo

The environment prompt will have absolute path to the environment, to shorten it, use the trick mentioned at the link above.

like image 106
anurag Avatar answered Oct 22 '22 13:10

anurag


In case other people encounter the same problem, as suggested in one of the comments here:

conda config --add pkgs_dirs /new_path_pkgs/

Verify that the pkgs_dirs path is changed:

conda config --show

The packages will be now saved in the new path.

like image 37
cgaldi Avatar answered Oct 22 '22 12:10

cgaldi