How to install multiple packages in conda from a file without creating a new environment?

21,354

Conda Env Update

If you have a YAML file, then the most efficacious way to apply it to a given env is with conda env update:

conda env update --file environment.yml

⚠️ Warning: The conda env commands don't prompt you to review and approve the transactions - it simply executes the changes. Be sure to carefully review the YAML file to ensure all of the changes are desired.

Conda Install

The format that Conda accepts for conda install --file is that which matches the output of conda list --export. It's not a YAML, but a simple text file with one package per line, similar to the one produced by pip freeze, except for the single equality sign ('=' rather than ==).

conda list --export

appdirs=1.4.3=py36h28b3542_0
asn1crypto=0.24.0=py36_0
...
zope=1.0=py36_1
zope.interface=4.5.0=py36h1de35cc_0

Note that the builds are not required, e.g., the following would also work and may actually be slightly more portable across architectures

appdirs=1.4.3
asn1crypto=0.24.0
...
zope=1.0
zope.interface=4.5.0

Unfortunately, conda install doesn't support PyPI packages; you'd have to install those separately via pip install in your activated env.

Share:
21,354
O.rka
Author by

O.rka

I am an academic researcher studying machine-learning and microorganisms

Updated on January 07, 2022

Comments

  • O.rka
    O.rka over 2 years

    I took these from yml file of packages that my current environment is missing. How do I just install these within my current environment?

    channels:
      - defaults
    dependencies:
      - appdirs=1.4.3=py36h28b3542_0
      - asn1crypto=0.24.0=py36_0
      - attrs=18.2.0=py36h28b3542_0
      - blas=1.0=mkl
      - cffi=1.11.5=py36h6174b99_1
      - constantly=15.1.0=py36h28b3542_0
      - cryptography=2.3.1=py36hdbc3d79_0
      - freetype=2.9.1=hb4e5f40_0
      - html5lib=1.0.1=py36_0
      - idna=2.7=py36_0
      - incremental=17.5.0=py36_0
      - intel-openmp=2019.0=118
      - libgfortran=3.0.1=h93005f0_2
      - libxml2=2.9.4=0
      - libxslt=1.1.29=hc208041_6
      - lxml=4.1.1=py36h6c891f4_0
      - mkl=2019.0=118
      - mkl_fft=1.0.6=py36hb8a8100_0
      - mkl_random=1.0.1=py36h5d10147_1
      - numpy=1.15.3=py36h6a91979_0
      - numpy-base=1.15.3=py36h8a80b8c_0
      - pyasn1=0.4.4=py36h28b3542_0
      - pyasn1-modules=0.2.2=py36_0
      - pycparser=2.19=py36_0
      - pyopenssl=18.0.0=py36_0
      - service_identity=17.0.0=py36h28b3542_0
      - twisted=17.5.0=py36_0
      - zope=1.0=py36_1
      - zope.interface=4.5.0=py36h1de35cc_0
      - pip:
        - absl-py==0.2.2
        - ete3==3.1.1
        - grpcio==1.12.1