keflavich
keflavich

Reputation: 19215

Install a package into multiple/all conda environments?

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?

Upvotes: 13

Views: 9528

Answers (3)

Jannick
Jannick

Reputation: 93

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

Upvotes: 5

abalter
abalter

Reputation: 10383

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

Upvotes: 16

asmeurer
asmeurer

Reputation: 91490

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.

Upvotes: 8

Related Questions