7
votes

I'm using conda to run tests against different versions of python, numpy, etc., but there are some common dependencies for all combinations of python/numpy. Is there a way to install such packages into all conda environments, or do I have to specify each by hand?

3

3 Answers

10
votes

You can run a shell loop over the output of conda env list. For example:

for env in $(conda env list | cut -d" " -f1 | tail -n+4); do conda install -n $env XXXXXX; done
6
votes

There's no simple command to do this, but one thing that may help is to make a metapackage using the conda metapackage command that depends on the packages you want, so that you can install just it. Something like conda metapackage mypackage 1.0 --dependencies package1 package2 package3 ....

Otherwise, you probably just need to make clever use of xargs.

4
votes

Instead of using a for loop in @abalter's answer, you can do it with xargs too. Note, this will only work for environment names without spaces:

conda env list | cut -d" " -f1 | tail -n+4 | xargs -L 1 conda install YOUR_PACKAGE -n