Install only available packages using "conda install --yes --file requirements.txt" without error
While installing packages in requirements.txt using conda through the following command
conda install --yes --file requirements.txt
If a package in requirements.txt is not available then it throws a "No package error" such as the one shown below:
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ....
Error: No packages found in current linux-64 channels matching: nimfa ==1.2.3
You can search for this package on anaconda.org with
> anaconda search -t conda nimfa ==1.2.3 >
Instead of throwing an error, is it possible to change this behavior such that it installs all the available packages in requirements.txt and throws a warning for those that are not available?
I would like this because, the package nimfa which the error says is not available, can be pip installed. So if i can change the behavior of
conda install --yes --file requirements.txt to just throw a warning for unavailable packages, i can follow it up with the command
pip install -r requirments.txt in .travis.yml so TravisCI attempts to install it from either place where it is available.
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"
★ Back to homepage or read more recommendations: