Article
7 comments

How to install dependencies from a requirements.txt file with conda

Just a little reminder: pip has this very useful option to install a bunch of packages from a single text file mostly called requirements.txt. Anaconda’s command line tool conda doesn’t support this option directly. It does support reading the package names from a file using the –yes and –file option

conda install --yes --file requirements.txt

but that does not automatically install all the dependencies. To do this, we need to iterate over the file and install each package in “single package mode”:

while read requirement; do conda install --yes $requirement; done < requirements.txt

Thanks to Luis Capelo for this snippet which I use to install dependencies in a dockerized instance of Anaconda / Jupyter (more on that in a later post).

7 Comments

    • From a Windows command prompt –

      for /F %i in (‘type requirements.txt’) do conda install –yes %i

      Reply

  1. Wow this is a serious gap in the product given that anaconda is suppose to simplify package and environment management.

    Thanks for posting the snippet.

    Reply

  2. the following worked for me
    conda create –name env_name –file requirements.txt

    Reply

Leave a Reply

Required fields are marked *.