Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to specify a conda config into an environment file?

Tags:

conda

anaconda

I use environment files to create new conda environments.

Unfortunately, my current project depends on the free channel, which has been removed from the default channel in newer versions of anaconda. It can be enabled by calling

    conda config --set restore_free_channel true
    # More generally, a config is set by:
    # conda config --set <key> <value>

This modifies the user's ~/.condarc. Since this may have side-effects, I would like to add this config to the environment file, instead of globally setting the conda configs. Is this possible? And if yes, how?

like image 582
normanius Avatar asked Nov 19 '25 09:11

normanius


1 Answers

I was able to add the free channel like you would any other, without changing my config:

name: test-env
channels:
  - free
  - defaults
dependencies:
  - python=2.*
  - beautiful-soup

Output of conda list -n test-env:

# packages in environment at ****/opt/miniconda3/envs/test-env:
#
# Name                    Version                   Build  Channel
beautiful-soup            4.3.2                    py27_0    free
certifi                   2016.2.28                py27_0    free
openssl                   1.0.2l                        0    free
pip                       9.0.1                    py27_1    free
python                    2.7.13                        0    free
readline                  6.2                           2    free
setuptools                36.4.0                   py27_1    free
sqlite                    3.13.0                        0    free
tk                        8.5.18                        0    free
wheel                     0.29.0                   py27_0    free
zlib                      1.2.11                        0    free

Specifying the channel for a particular package also works:

name: test-env
channels:
  - defaults
dependencies:
  - python=2.*
  - free::beautiful-soup

Output of conda list -n test-env:

# packages in environment at ****/opt/miniconda3/envs/test-env:
#
# Name                    Version                   Build  Channel
beautiful-soup            4.3.2                    py27_0    free
ca-certificates           2020.1.1                      0  
certifi                   2019.11.28               py27_0  
libcxx                    4.0.1                hcfea43d_1  
libcxxabi                 4.0.1                hcfea43d_1  
libedit                   3.1.20181209         hb402a30_0  
libffi                    3.2.1                h475c297_4  
ncurses                   6.2                  h0a44026_0  
pip                       19.3.1                   py27_0  
python                    2.7.17               h97142e2_0  
readline                  7.0                  h1de35cc_5  
setuptools                44.0.0                   py27_0  
sqlite                    3.31.1               ha441bb4_0  
tk                        8.6.8                ha441bb4_0  
wheel                     0.33.6                   py27_0  
zlib                      1.2.11               h1de35cc_3 
like image 74
AMC Avatar answered Nov 21 '25 09:11

AMC