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.
Use the pip install -r requirements. txt command to install all of the Python modules and packages listed in your requirements. txt file.
The fundamental difference between pip and Conda packaging is what they put in packages. Pip packages are Python libraries like NumPy or matplotlib . Conda packages include Python libraries (NumPy or matplotlib ), C libraries ( libjpeg ), and executables (like C compilers, and even the Python interpreter itself).
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With