Is there a way to install all the packages listed in a requirements file except for specific ones?
I have a big requirements file and need to install all the packages listed there except for a few (e.g.
I have tried using
pip install -r requirements.txt --except=pytorch,torchvision but it seems like this option is not supported by pip (as can be seen in the pip options).
Is there another way to do this?
One way to achieve this is by making a copy of the original requirements file, removing the lines corresponding to the packages you want to exclude, and then installing the remaining packages using
pip install -r <new_requirements_file>. For example, assuming your original requirements file is called
requirements.txt, you can create a new file called
new_requirements.txt that excludes
torchvision by running the following command:
grep -v 'pytorch\|torchvision' requirements.txt > new_requirements.txt
This will create a copy of
new_requirements.txt, but with all lines containing
torchvision removed. You can then install the remaining packages using:
pip install -r new_requirements.txt
This will install all packages listed in
new_requirements.txt, except for