Install only available packages using "conda install --yes --file requirements.txt" without error

I ended up just iterating over the lines of the file

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

Edit: If you would like to install a package using pip if it is not available through conda, give this a go:

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

Edit: If you are using Windows (credit goes to @Clay):

$ FOR /F "delims=~" %f in (requirements.txt) DO conda install --yes "%f" || pip install "%f"


You can do this as mentioned in this

Export to .yml file

conda env export > freeze.yml

To reproduce:

conda env create -f freeze.yml